2011-08-19 15 views
9

Dòng 13 trong tài liệu XML từ tài nguyên đường dẫn lớp [ApplicationContextAOP.xml] không hợp lệ; ngoại lệ lồng nhau là org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: Ký tự đại diện phù hợp là nghiêm ngặt, nhưng không thể khai báo cho phần tử 'aop: config'.Spring AOP Ký tự đại diện phù hợp là nghiêm ngặt, nhưng không thể khai báo cho phần tử '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> 

Tôi đã nhìn thấy lỗi tương tự và tôi khá chắc chắn classpath của tôi có org.springframework.aop-3.1.0.M2.jar

Ông có thể cho tôi biết những gì xin vui lòng pm Tôi bị mất?

+0

Cảm ơn bạn rất nhiều vì câu hỏi của bạn. Tôi đã phải đối mặt với cùng một vấn đề, nhưng trong trường hợp của tôi vấn đề là tôi đã thiếu 'spring-aop.jar' trong classpath; đó là những gì tôi đã mất tích. Cảm ơn vì đã chú ý đến điều đó. – manuelvigarcia

Trả lời

22

Bạn cần phải thêm vào schemaLocation của bạn:

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

Bây giờ tôi nhận được điều này :-(Ngoại lệ trong chủ đề "chính" org.springframework.beans.factory.BeanDefinitionStoreException: Ngoại lệ không mong muốn phân tích cú pháp tài liệu XML từ tài nguyên đường dẫn lớp [ApplicationContextAOP.xml]; ngoại lệ lồng nhau là java.lang.NoClassDefFoundError: org/aopalliance/aop/Advice – Aubergine

+3

Bạn đang bỏ lỡ [aopalliance jar] (http://search.maven.org/#artifactdetails |aopalliance |aopalliance|1.0|jar). –

+1

@Aubergine: Bạn nên chấp nhận câu trả lời này là câu trả lời đúng và đặt một câu hỏi mới –

0

Chúng tôi đã nhận được thông báo lỗi tương tự cho các phần tử tx:advice và bị nó giải quyết bằng cách thay thế org.springframework.*-3.0.0.M3.jar s với org.springframework.*-3.1.2.RELEASE.jar là nơi * đại diện cho module jar. Do đó, hãy thử tải bản phát hành ổn định để khắc phục các sự cố tương tự.

0
 
Adding one more possibility to the earlier provided answers : 

Wrong version of schemaLocation: 
http://www.springframework.org/schema/aop/ 
    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" 
Các vấn đề liên quan