Spring AOP错误
运行时什么会导致这个问题?:
通配符的匹配是严格的,但是 找不到声明 元素“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.jar 和 aspectjrt.jar 放在类路径上。
What would cause this problem at run-time?:
The matching wildcard is strict, but
no declaration can be found for
element 'aop:config'
Here is the relevant 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>
Note that I’ve already put aspectjweaver.jar and aspectjrt.jar on the class path.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
确保
/dist/modules/spring-aop.jar
在您的类路径中。Make sure that
<spring-framework-directory>/dist/modules/spring-aop.jar
is in your class path.对于其他人,我在配置中解决了此错误,其中命名空间包含该项目
,但未包含 xsi:schemaLocation 元素
此配置错误导致了上述消息。
添加 schemaLocation 元素解决了这个问题。
For anyone else, I resolved this error in my configuration, where the namespace included the item
though had not included the xsi:schemaLocation elements
This configuration error caused the message above.
Adding in the schemaLocation elements resolved it.
您是否仔细检查了类路径上的 spring aop 工件?
根据我的maven依赖关系,aspectjweaver是不够的,我还需要aspectjrt。
Did you doublecheck the spring aop artifact on classpath ?
And according to my maven dependencies, aspectjweaver is not enough, i needed also aspectjrt.