Spring AOP Соответствующий подстановочный знак является строгим, но не найдено никакого объявления для элемента 'aop: config' - PullRequest
9 голосов
/ 20 августа 2011

Строка 13 в документе XML из ресурса пути к классу [ApplicationContextAOP.xml] недопустима; Вложенное исключение: 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>

Я видел похожую ошибку, и я почти уверен, что мой classpath имеет org.springframework.aop-3.1.0.M2.jar

Не могли бы вы сказать мне, что мне не хватает?

Ответы [ 3 ]

22 голосов
/ 20 августа 2011

Вам необходимо добавить в свою схему расположение:

xsi:schemaLocation="
...
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
...
"
0 голосов
/ 17 июля 2017
Adding one more possibility to the earlier provided answers : 

Wrong version of schemaLocation:
http://www.springframework.org/schema/aop<b>/</b> 
    http://www.springframework.org/schema/aop/spring-aop-3.0.xsd 

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

REASON: The extra "/" after "schema/aop"
0 голосов
/ 12 сентября 2012

Мы получили аналогичное сообщение об ошибке для элемента tx:advice и получили его разрешение путем замены org.springframework.*-3.0.0.M3.jar s на org.springframework.*-3.1.2.RELEASE.jar s, где * представляет модули jar.Поэтому попробуйте получить стабильную версию, чтобы исправить подобные проблемы.

...