Java 错误:升级到Spring 3.2.3.0版本后,找不到元素[component scan]的BeanDefinitionParser
将spring升级到3.2.3.RELEASE后,在Eclipse中启动Tomcat时出现以下错误:Java 错误:升级到Spring 3.2.3.0版本后,找不到元素[component scan]的BeanDefinitionParser,java,rest,spring-mvc,xsd,spring-ws,Java,Rest,Spring Mvc,Xsd,Spring Ws,将spring升级到3.2.3.RELEASE后,在Eclipse中启动Tomcat时出现以下错误: ug 12, 2013 1:59:14 AM org.apache.catalina.core.StandardContext listenerStart SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.Context
ug 12, 2013 1:59:14 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.IllegalArgumentException: Cannot locate BeanDefinitionParser for element [component-scan].
at org.springframework.beans.factory.xml.NamespaceHandlerSupport.findParserForElement(NamespaceHandlerSupport.java:63)
at org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser.parseCustomElement(DefaultXmlBeanDefinitionParser.java:399)
at org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser.parseBeanDefinitions(DefaultXmlBeanDefinitionParser.java:358)
at org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser.registerBeanDefinitions
以下是我的applicationContext.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:p="http://www.springframework.org/schema/p"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.2.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd">
<context:component-scan base-package="merchant" />
<context:component-scan
base-package="merchant.domain" />
<context:component-scan
base-package="merchant.controller" />
<context:component-scan
base-package="merchant.repo" />
<context:component-scan
base-package="merchant.service" />
<!-- Load Hibernate related configuration -->
<import resource="hibernate-context.xml" />
<tx:annotation-driven/>
<mvc:annotation-driven/>
</beans>
我在网上搜索了很多解决方案,但找不到任何相关的。
请帮忙!
提前谢谢 此错误很可能是因为升级后在类路径中找不到
spring-context-3.2.3.RELEASE.jar
。请检查您的依赖关系,并确保此jar在依赖关系列表中。谢谢您的回复。我查过了。在类路径中可以正确找到jar。由于旧版本的Spring,我遇到了另一个问题,这个问题得到了解决。因此,它必须起作用。但是我还是得到了上面的错误。奇怪……我想不出还有什么别的,有没有其他的spring上下文jar被检测到的方法?另外,请查看是否可以找到这种类型,org.springframework.context.config.ContextNamespaceHandler
,这是处理上下文
命名空间的类。我包括了spring-2.5.6.jar,其中包含上述类。仍然是相同的错误。这与我在applicationContext.xml内的xsi:schemaLocation中提到的spring版本有关吗?spring-2.5.6是一个旧版本。如果要将spring-context-3.2.3与spring-2.5.6混合使用,我只需继续并删除旧版本。这应该可以解决问题。