2012-08-17 3 views
2

스프링 프레임 워크 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

+0

클래스 경로에 필요한 Jar가 있습니까? –

+0

물론 나는 classpath에 모든 봄 항아리가 있습니다. – user902691

+1

이 클래스는 Spring의 일부가 아닙니다. aopalliance.jar가 필요합니다. http://sourceforge.net/projects/aopalliance/files/ –

답변

1

나는 스프링을 실제로 사용하면서 봄을 배우는 것으로 생각한다. 사실 com.springsource.org.apoalliance.jar 파일이 누락되었습니다.이 파일은 org.springframework.aop.jar에 포함되지 않습니다 (이유는 모르지만). 당신이 당신의 클래스 패스에 항아리를 포함하지 않기 때문에 당신은 Caused by: java.lang.ClassNotFoundException: org.aopalliance.aop.Advicehttp://sourceforge.net/projects/aopalliance/files/aopalliance/

:

에서 다운로드하시기 바랍니다.