加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java – 无法找到XML模式命名空间的Spring NamespaceHandler [ht

发布时间:2020-12-15 03:08:34 所属栏目:Java 来源:网络整理
导读:任何想法,什么可能导致此错误? org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/data/jp
任何想法,什么可能导致此错误?

org.springframework.beans.factory.parsing.BeanDefinitionParsingException:
Configuration problem: Unable to locate Spring NamespaceHandler for
XML schema namespace [http://www.springframework.org/schema/data/jpa]
Offending resource: ServletContext resource
[/WEB-INF/spring/appServlet/servlet-context.xml]

这是我的’servle-context.xml'(缩进有一些问题,但是文件太大了……):

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="http://www.springframework.org/schema/mvc 
                    http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
                    http://www.springframework.org/schema/beans 
                    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                    http://www.springframework.org/schema/tx 
                    http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
                    http://www.springframework.org/schema/data/jpa 
                    http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
                    http://www.springframework.org/schema/context 
                    http://www.springframework.org/schema/context/spring-context-3.0.xsd">

<!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->

<!-- Enables the Spring MVC @Controller programming model -->
<annotation-driven />

<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
<resources mapping="/resources/**" location="/resources/" />

<!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <beans:property name="prefix" value="/WEB-INF/views/" />
    <beans:property name="suffix" value=".jsp" />
</beans:bean>

<context:component-scan base-package="com.epam.mvc3.model" />
<context:component-scan base-package="com.epam.mvc3.controller" />

<!-- JPA -->
<beans:bean
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <beans:property name="location">
        <beans:value>resources/database.properties</beans:value>
    </beans:property>
</beans:bean>

<beans:bean id="myDataSource"
    class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <beans:property name="driverClassName">
        <beans:value>${jdbc.driverClassName}</beans:value>
    </beans:property>
    <beans:property name="url">
        <beans:value>${jdbc.url}</beans:value>
    </beans:property>
    <beans:property name="username">
        <beans:value>${jdbc.username}</beans:value>
    </beans:property>
    <beans:property name="password">
        <beans:value>${jdbc.password}</beans:value>
    </beans:property>
</beans:bean>

<beans:bean id="myEmf"
    class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <beans:property name="dataSource" ref="myDataSource" />

    <beans:property name="persistenceUnitName" value="application" />
    <beans:property name="persistenceXmlLocation"
        value="classpath*:META-INF/persistence.xml" />
    <beans:property name="jpaVendorAdapter" ref="hibernateVendor" />

    <beans:property name="loadTimeWeaver">
        <beans:bean
            class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"></beans:bean>
    </beans:property>
</beans:bean>

<beans:bean id="hibernateVendor"
    class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
</beans:bean>

<beans:bean id="transactionManager"
    class="org.springframework.orm.jpa.JpaTransactionManager">
    <beans:property name="entityManagerFactory" ref="myEmf"></beans:property>
</beans:bean>

<tx:annotation-driven transaction-manager="transactionManager" />

<!-- Spring Data configuration -->
<jpa:repositories base-package="com.epam.mvc3.repository"/>

</beans:beans>

如您所见,我指定了jpa-schema的路径.我不知道是什么问题

解决方法

尝试更换

http://www.springframework.org/schema/data/jpa/spring-jpa.xsd

通过

http://www.springframework.org/schema/data/jpa/spring-jpa-1.0.xsd

但是,如果您仍然使用版本1.0-M1,请先尝试更新. DATAJPA-21

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读