错误:升级到Spring 3.2.3.RELEASE后无法找到元素[component-scan]的BeanDefinitionParser

时间:2013-08-11 20:37:54

标签: 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.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>

我在线搜索了很多解决方案,但找不到相关的解决方案。 请帮忙! 提前谢谢!

1 个答案:

答案 0 :(得分:0)

此错误很可能是因为升级后在类路径中找不到spring-context-3.2.3.RELEASE.jar。请检查您的依赖项,并确保此jar位于依赖项列表中。