2009-05-18 62 views
3

什麼會導致在運行時這個問題?:Spring AOP的錯誤

匹配通配符是嚴格的,但 沒有聲明可以 元素中找到「AOP:配置」

下面是相關的Spring XML:

<beans xmlns="http://www.springframework.org/schema/beans" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns:util="http://www.springframework.org/schema/util" 
     xmlns:aop="http://www.springframework.org/schema/aop" 
     xsi:schemaLocation="http://www.springframework.org/schema/beans 
     http://www.springframework.org/schema/beans/spring-beans-2.0.xsd 
     http://www.springframework.org/schema/util 
     http://www.springframework.org/schema/util/spring-util-2.0.xsd 
     http://www.springframework.org/schema/aop 
     http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> 
    . 
    . 
    . 
    <aop:config> 
     <aop:advisor pointcut="execution(* acme.exam.driver.ui.components..*(..))" 
        advice-ref="loggingInterceptor" /> 
    </aop:config> 

    <bean id="loggingInterceptor" 
      class="org.springframework.aop.interceptor.CustomizableTraceInterceptor"> 
     <property name="enterMessage" 
        value="ENTER: $[targetClassShortName].$[methodName]($[arguments])" /> 
     <property name="exitMessage" 
        value="EXIT: $[targetClassShortName].$[methodName]($[arguments]) = $[returnValue])" /> 
    </bean> 
</beans> 

請注意,我已經把aspectjweaver.jaraspectjrt.jar上的類路徑。

回答

2

你是否在類路徑中檢查了spring aop神器?

而根據我的maven依賴關係,aspectjweaver是不夠的,我還需要aspectjrt。

+0

什麼是「春天aop神器」? – 2009-05-18 18:09:44

0

確保<spring-framework-directory>/dist/modules/spring-aop.jar在您的課程路徑中。

0

對於其他人,我在我的配置,其中命名空間包含的項目

xmlns:aop="http://www.springframework.org/schema/aop 
解決了這個錯誤

雖然沒有包括XSI:的schemaLocation元素

http://www.springframework.org/schema/aop 
http://www.springframework.org/schema/aop/spring-aop.xsd 

此配置錯誤導致上面的消息。
在schemaLocation元素中添加解析它。