2013-06-05 27 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

感謝。我在故障排除中改變了一大堆早期的路徑,而且我很難試圖找到導致問題的各條線路。 –