2013-06-05 35 views
0

在同一项目中的一个包中,我使用@Autowired从我的appcontext.xml中获取元素,并且它工作正常。在同一个appcontext中定义的bean,然后是@Autowired,已成功创建,但没有尝试注入bean。@Autowired未在一个包中找到,但在另一个包中找到

我感觉好像我可能会丢失与类路径相关的东西。现在,我一直想在我的appcontext添加<context:component-scan />,但只给了我这个错误:我AppContext.xml的

org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'context:component-scan'.

部分:

<?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:p="http://www.springframework.org/schema/p" 
    xmlns:aop="http://www.springframework.org/schema/aop" 
    xmlns:tx="http://www.springframework.org/schema/tx" 
    xmlns:context="http://www.springframework.org/schema/context/spring-context-2.5.xsd" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans-2.5.xsd 
    http://www.springframework.org/schema/aop 
    http://www.springframework.org/schema/aop/spring-aop-2.5.xsd 
    http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/context/spring-context-2.5.xsd 
    http://www.springframework.org/schema/tx 
    http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> 

    <context:component-scan base-package="org.jasig.cas.web.flow"/> 

随着豆类定义进一步低于它。

任何明显的缺陷,还是有一些其他配置我应该改变?

回答

3

线xmlns:context="http://www.springframework.org/schema/context/spring-context-2.5.xsd" 应该简单地xmlns:context="http://www.springframework.org/schema/context"

+0

感谢。我在故障排除中改变了一大堆早期的路径,而且我很难试图找到导致问题的各条线路。 –