Spring上下文:组件扫描转换异常

时间:2014-04-11 15:13:50

标签: spring spring-mvc applicationcontext

我有一个奇怪的错误,我在互联网上搜索了很多。我无法理解为什么我收到此错误。我在春季jira上找到了关于这个错误的一些解释。我在context:component-scan中有applicationContext.xml,我在com.sow.webservices包中定义了5个包。但是,当我添加包含控制器类的控制器包时,我抛出

Error occured processing XML '[Ljava.lang.String; cannot be cast to java.lang.String'. See Error Log for more details

这是组件扫描:

<context:component-scan base-package="com.sow.webservices.aop, 
                                          com.sow.webservices.exceptions,
                                          com.sow.webservices.models, 
                                          com.sow.webservices.services,
                                          com.sow.webservices.controller">

我想向您展示整个异常跟踪。感谢您的帮助。

!ENTRY org.springframework.ide.eclipse.beans.core 1 0 2014-04-11 18:07:39.996
!MESSAGE Error occured processing '/SOW_WS/src/main/webapp/WEB-INF/applicationContext.xml'
!STACK 0
java.lang.ClassCastException: [Ljava.lang.String; cannot be cast to java.lang.String
    at org.springframework.context.annotation.AnnotationBeanNameGenerator.determineBeanNameFromAnnotation(AnnotationBeanNameGenerator.java:92)
    at org.springframework.context.annotation.AnnotationBeanNameGenerator.generateBeanName(AnnotationBeanNameGenerator.java:70)
    at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:247)
    at org.springframework.context.annotation.ComponentScanBeanDefinitionParser.parse(ComponentScanBeanDefinitionParser.java:85)
    at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:74)
    at org.springframework.ide.eclipse.beans.core.internal.model.namespaces.DelegatingNamespaceHandlerResolver$ElementTrackingNamespaceHandler.parse(DelegatingNamespaceHandlerResolver.java:177)
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1427)
    at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$ErrorSuppressingBeanDefinitionParserDelegate.parseCustomElement(BeansConfig.java:1400)
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1417)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:187)
    at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$ToolingFriendlyBeanDefinitionDocumentReader.doRegisterBeanDefinitions(BeansConfig.java:1330)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:110)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:494)
    at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$2.registerBeanDefinitions(BeansConfig.java:402)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:391)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:335)
    at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$2.loadBeanDefinitions(BeansConfig.java:388)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)
    at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$3.call(BeansConfig.java:445)
    at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$3.call(BeansConfig.java:1)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

即使xml抛出此异常,我也可以运行我的应用程序,但是当我删除com.sow.webservices.controller时,它会停止显示有错误符号,但它会出现404错误。由于我遇到组件扫描问题,LocaleChangeInterceptor无法正常工作,我无法将我的应用程序国际化

1 个答案:

答案 0 :(得分:5)

检查你的控制器,如果其中一个使用注释@ControllerAdvice尝试注释掉它,奇怪的是错误消失了。 FREAKY !!!!