스프링 프레임 워크 3.1.2로 AOP를 배우기 시작합니다. 그러나 나는 문제가있다. Beans.xml
컨텍스트 파일에서 내가 쓴 :AOP (스프링 애스펙트 경고)
<?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"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd ">
<bean id = "audience" class="com.MySpring.Audience"></bean>
<aop:config>
<aop:aspect ref="audience">
<aop:pointcut id="performance" expression="execution(* com.MySpring.Performer.perform(..))"/>
<aop:before pointcut-ref="performance" method="seatDown"/>
<aop:before pointcut-ref="performance" method="turnOffPhone"/>
<aop:after-returning pointcut-ref="performance" method="applauz"/>
<aop:after-throwing pointcut-ref="performance" method="demandRefund"/>
</aop:aspect>
</aop:config>
</beans>
그리고 자바 클래스
public class AOPTest {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
ApplicationContext context = new ClassPathXmlApplicationContext(
"Beans.xml");
}
}
// ///
class Audience {
public void seatDown() {
out.println("Seat down");
}
public void turnOffPhone() {
out.println("Turn Off Phone");
}
public void applauz() {
out.println("Aplauz");
}
public void demandRefund() {
out.println("We have money back");
}
}
////
interface Performer{
void perform();
}
그러나 오류 콘솔에서 난을 참조하십시오
Description Resource Path Location Type Error occured processing XML 'class path resource [org/aopalliance/aop/Advice.class] cannot be opened because it does not exist'. See Error Log for more details Beans.xml /AnnotationsWiring/src line 11 Spring Beans Problem
그리고 두 번째 오류 :
Description Resource Path Location Type Error occured processing XML 'org/springframework/aop/aspectj/AspectJMethodBeforeAdvice'. See Error Log for more details Beans.xml /AOP/src line 12 Spring Beans Problem
클래스 경로에 필요한 Jar가 있습니까? –
물론 나는 classpath에 모든 봄 항아리가 있습니다. – user902691
이 클래스는 Spring의 일부가 아닙니다. aopalliance.jar가 필요합니다. http://sourceforge.net/projects/aopalliance/files/ –