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



从类路径资源[ApplicationContextAOP.xml]的XML文档中的第13行无效;cvc-complex-type. 2.4.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. m1 .jar

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

您需要添加到schemaLocation:

xsi:schemaLocation="
...
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
...
"
在之前提供的答案中添加另一种可能性:schemaLocation的错误版本:http://www.springframework.org/schema/aop /http://www.springframework.org/schema/aop/spring-aop-3.0.xsd正确的版本:http://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop-3.0.xsd原因:"schema/aop"后面多了一个"/"

对于元素tx:advice,我们收到了类似的错误消息,并通过将org.springframework.*-3.0.0.M3.jar s替换为org.springframework.*-3.1.2.RELEASE.jar s来解决此问题,其中*表示jar模块。因此,尝试获得一个稳定的版本来修复类似的问题。

我在使用以下模式定义文件时遇到了这种情况。原因是额外的>在spring-aop-3.0.xsd之后。删除后解决。

<?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:context="http://www.springframework.org/schema/context"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:jdbc="http://www.springframework.org/schema/jdbc"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
                            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
                            http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd>
                            http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd">
<!--    reference to tht jdbc name space and schema definition file-->
    <!--    to enable AspectJ support-->
    <aop:aspectj-autoproxy/>
    
 </beans>
    

最新更新