Spring AOP 错误

4

什么原因会导致这个问题在运行时出现?:

匹配通配符是严格的,但找不到元素“aop:config”的声明

以下是相关的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 放在类路径上。
3个回答

2

你是否仔细检查了类路径上的spring aop组件?

根据我的maven依赖关系,只有aspectjweaver是不够的,我还需要aspectjrt。


什么是“spring aop artifact”? - Paul Reiners
看起来你找到了工件名称 :-) - Michael Pralow

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元素解决了它。


0
确保<spring-framework-directory>/dist/modules/spring-aop.jar在你的类路径中。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接