将 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.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>
我在网上搜索了很多解决方案,但找不到任何相关的解决方案。请帮忙!提前致谢!