gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 02:50:51 27 4
gpt4 key购买 nike

来自类路径资源 [ApplicationContextAOP.xml] 的 XML 文档中的第 13 行无效;嵌套异常是 org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: 匹配的通配符是严格的,但找不到元素 的声明'aop:config' .

<?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://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<bean id="audience" class="com.idol.Audience" />

<aop:config>
<aop:aspect ref="audience">

<!-- Before performance -->

<aop:before pointcut="execution(*com.idol.performers.Performer.perform(..))"
method="takeSeats"/>

<aop:before pointcut="execution(*com.idol.performers.Performer.perform(..))"
method="turnOffCellPhones" />

<!-- After performance -->

<aop:after-returning pointcut="execution(*com.idol.performers.Performer.perform(..))"
method="applaud" />

<!-- After bad performance(exception thrown) -->

<aop:after-throwing pointcut="execution(*com.idol.performers.Performer.perform(..))"
method="demandRefund" />

</aop:aspect>
</aop:config>
<bean id="poeticDuke" class="com.idol.performers.PoeticJuggler">
<constructor-arg value = "15" />
<constructor-arg ref = "sonnet29" />
</bean>

</beans>

我见过类似的错误,我很确定我的类路径有 org.springframework.aop-3.1.0.M2.jar

你能告诉我我错过了什么吗?

最佳答案

您需要添加到您的 schemaLocation:

xsi:schemaLocation="
...
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
...
"

关于Spring AOP 匹配通配符严格,但是找不到元素 'aop:config'的声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7127930/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com