Spring Servlet-Context.xml 错误无法找到元素 [import] 的 BeanDefinitionParser
Spring Servlet-Context.xml error Cannot locate BeanDefinitionParser for element [import]
我在 Eclipse 中有一个由 STS 插件生成的 spring 项目,我正在尝试导入一个 spring-ws 文件,该文件与 servlet-context.xml 在同一目录中但得到错误。下面列出了 servlet 上下文文件
<?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:beans="http://www.springframework.org/schema/beans"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:oxm="http://www.springframework.org/schema/oxm"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-1.5.xsd">
<import resource="spring-ws.xml" />
<!-- 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>
<jpa:repositories base-package="com.crgl.crm" />
<beans:bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
<beans:property name="persistenceUnitName" value="defaultPersistenceUnit" />
</beans:bean>
<beans:bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager">
<beans:property name="entityManagerFactory" ref="entityManagerFactory" />
</beans:bean>
<tx:annotation-driven transaction-manager="transactionManager" />
<context:component-scan base-package="com.crgl.crm" />
<context:property-placeholder location="classpath:Services.properties" />
</beans:beans>
我得到的错误是
在此行找到多个注释:
配置问题:找不到元素 [import]
的 BeanDefinitionParser
在您的 XML 中,您已将 spring-mvc.xsd
设为首位。 mvc
命名空间不包含元素 import
,但是 spring-beans.xsd
包含元素。
您需要将 beans
前缀添加到 import
元素才能使其正常工作。
<beans:import resource="spring-ws.xml" />
就像来自同一命名空间的 bean
标签一样。
我在 Eclipse 中有一个由 STS 插件生成的 spring 项目,我正在尝试导入一个 spring-ws 文件,该文件与 servlet-context.xml 在同一目录中但得到错误。下面列出了 servlet 上下文文件
<?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:beans="http://www.springframework.org/schema/beans"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:oxm="http://www.springframework.org/schema/oxm"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-1.5.xsd">
<import resource="spring-ws.xml" />
<!-- 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>
<jpa:repositories base-package="com.crgl.crm" />
<beans:bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
<beans:property name="persistenceUnitName" value="defaultPersistenceUnit" />
</beans:bean>
<beans:bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager">
<beans:property name="entityManagerFactory" ref="entityManagerFactory" />
</beans:bean>
<tx:annotation-driven transaction-manager="transactionManager" />
<context:component-scan base-package="com.crgl.crm" />
<context:property-placeholder location="classpath:Services.properties" />
</beans:beans>
我得到的错误是 在此行找到多个注释: 配置问题:找不到元素 [import]
的 BeanDefinitionParser在您的 XML 中,您已将 spring-mvc.xsd
设为首位。 mvc
命名空间不包含元素 import
,但是 spring-beans.xsd
包含元素。
您需要将 beans
前缀添加到 import
元素才能使其正常工作。
<beans:import resource="spring-ws.xml" />
就像来自同一命名空间的 bean
标签一样。