2012-02-25 2 views
0

나는에 의한 웹 애플리케이션 시작스프링 AOP 표현

에이 오류를 받고 있어요 : 오류는 이름을 가진 콩을 만드는 'org.springframework.aop.aspectj.AspectJPointcutAdvisor # 0 : org.springframework.beans.factory.BeanCreationException ': 빈의 실체화에 실패했습니다. 중첩 예외는 org.springframework.beans.BeanInstantiationException : Bean 클래스를 인스턴스화 할 수 없습니다 [org.springframework.aop.aspectj.AspectJPointcutAdvisor] : 생성자가 예외를 던졌습니다. 상자의 예외는 java.lang.IllegalArgumentException가 있습니다 : 오류에 일이

을 생략

여기에 바닥

<?xml version="1.0" encoding="UTF-8" standalone="no"?> 
    <beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:aop="http://www.springframework.org/schema/aop" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd 
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> 

에서 내 포인트 컷을 보여주는 XML의 일부입니다 ..... 포인트 컷에 :: 0 공식적인 언 바운드 내 클래스 중 하나에

<aop:config> 
    <aop:aspect id="bamAspectAroundID" ref="bamAspectAround"> 
     <aop:pointcut id="bamAroundMethodPointcut" expression="execution(* testBA*(..))" /> 
     <aop:around method="aspectAroundMethod" pointcut-ref="bamAroundMethodPointcut"/> 
    </aop:aspect> 
    </aop:config> 
, 나는 더미 방법

public void testBAM() { 
     System.out.println("in testBAM() "); 
    } 

expressi에게 있습니다 에 나에게 괜찮아 보인다. 어떤 포인터? aspectj 1.6.2를 사용하고 있습니다. 감사.

답변

0

AspectJ 표현이 정상적인 지 확인할 수 있습니다. 나는 당신이 우리에게 준 것과 그것을 사용하여 테스트 버전을 했어.

웹 컨테이너에서하지 않았습니다. Eclipse에서 AspectJ 도구 1.6.6과 AspectJ weaver 1.6.8과 Spring 3.1 라이브러리를 사용하여 독립 실행 형 Spring 응용 프로그램으로 만들었습니다. 버전의. 내 클래스 경로에

가로 세로 관련 jar 파일은 다음과 같습니다 :

  • 는 org.springframework.aop-3.1.0
  • org.springframework.aspects-3.1 여기

    내가 일한이 무엇 0.0
  • com.springsource.org.aspectj.tools-1.6.6
  • com.springsource.org.aspectj.weaver-1.6.8
  • 닷컴. springsetource.org.aopalliance-1.0.0

내 xml 구성의 AOP 부분은 사용자의 것과 모양이 비슷합니다. 변경되지 않습니다.

나는 같은 스프링 XML 설정 파일에 다음 bean 정의를 추가 :

<bean id="aspectTarget" class="foo.bam.Target" /> 
<bean id="bamAspectAround" class="foo.bam.BamAspectAround" /> 

대상 클래스가 testBAM() 방법이있다.

BamAspectAround에 대한 코드는 다음과 같습니다

주요 방법이있다
public class BamAspectAround { 
    public void aspectAroundMethod(ProceedingJoinPoint joinPoint) throws Throwable { 
    System.out.println(">>> BamAspectAround Before"); 
    joinPoint.proceed(); 
    System.out.println("<<< BamAspectAround After"); 
    } 
} 

:

Target t = (Target)ctx.getBean("aspectTarget"); 
t.testBAM(); 

을 그리고 그것은 내가 기대했던 아웃 출력 :

>>> BamAspectAround Before 
in testBAM() 
<<< BamAspectAround After 

: AspectJ 1.6.2를 다운로드하고 위버 jar를 그 도구 항아리 (1.6.8 것들을 제거) 내 클래스 경로에 위의도 근무, 그래서 아마도 귀하의 설치 프로그램과 간단한 예제를 시도하고 웹 배포 버전에서 누락 된 조각을 참조하십시오.