2016-01-30 37 views
2

我是一個新手,通過我的第一個JAVA Spring應用程序,主要基於Spring in Action第四版由Craig牆和我卡在這個錯誤...org.xml.sax.SAXParseException:匹配的通配符是嚴格的,但是沒有爲元素'aop:config'找到聲明

錯誤:

 
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: 
Line 20 in XML document from class path resource [Knights.xml] is invalid; 
nested exception is org.xml.sax.SAXParseException; lineNumber: 20; 
columnNumber: 14; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'aop:config'. 

我的應用程序的工作,我期望沒有XML文件中的<aop:config>標籤。

有問題的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://springframework.org/schema/aop" 
xsi:schemaLocation="http://www.springframework.org/schema/aop 
        http://www.springframework.org/schema/aop/spring-aop-4.2.xsd 
        http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans.xsd"> 

    <bean id="knight" class="knights.BraveKnight"> 
     <constructor-arg ref="quest" /> 
    </bean> 
    <bean id="quest" class="quests.SlayDragonQuest"> 
     <constructor-arg value="#(T(System).out)" /> 
    </bean> 
    <bean id="minstrel" class="epic.Minstrel"> 
     <constructor-arg value="#(T(System).out" /> 
    </bean> 

    <aop:config> 
     <aop:aspect ref="minstrel"> 
      <aop:pointcut id="embark" expression="execution(* *.embarkOnQuest(..))" /> 

      <aop:before pointcut-ref="embark" method="singBeforeQuest" /> 

      <aop:after pointcut-ref="embark" method="singAfterQuest" /> 
     </aop:aspect> 
    </aop:config> 
</beans> 

我會很感激的任何建議。 謝謝。

+0

您正在使用的是什麼版本的Spring? – Tunaki

+0

如果spring-aop在類路徑上,你應該檢查。如果您使用Maven,請執行'mvn dependency:tree'來獲取您的項目依賴關係列表。 – dunni

回答

0

嘗試在名稱空間元素中添加一個www:xmlns:aop="http://www.springframework.org/schema/aop"

相關問題