주석과 XML 방법 :
주석 방법 : 최소한의 XML 구성 파일 :
<!-- Enable autoproxy to pick up all Java files tagged as @Aspect behave like Aspects -->
<aspectj-autoproxy/>
<!-- define bean -->
<!-- Note: MyUselessAspect.java should exist and this class must be tagged as @Aspect -->
<bean id="myUselessAspect" class="...MyUselessAspect" />
XML 방법 : 최소한의 XML 구성 :
<aop:config>
<aop:aspect ref="myUselessAspect">
<!-- this point-cut picks all methods of any return type, from any package/class with any number of Parameters -->
<aop:before method="doSomethingBeforeMethodCall" pointcut="execution(* *.*(..))"/>
<aop:after method="doSomethingAfterMethodCall" pointcut="execution(* *.*(..))"/>
</aop:aspect>
</aop:config>
<!-- No need to Annotate this java Class as @Aspect. Neither you need to define any
Point-cuts or Advices in the Java file. The <aop:config> tag takes care of everything -->
<bean id="myUselessAspect" class="...MyUselessAspect"></bean>
코드를 변경할 필요가 없습니다.
전 필수 : AOP의 네임 스페이스는 AspectJ를를 사용하는 사람들의 이익을 위해 주목 XML 파일
에 존재하지만, 봄에 익숙하지 있어야합니다 - 여기 크람의 대답은 봄의 구성 측면을 구성하는 방법을 해결하고 파일. 또한 XML 구성 파일을 통해 aspect를 정의하는 * 세 번째 방법을 제공합니다. Spring이 아닌 AspectJ에서 직접 프로그래밍 할 때 AspectJ 설정 파일 (일반적으로 'aop.xml')에서 비슷한 기능을 사용할 수있다. 불행히도, 이것은 원래의 질문을 다루는 것이 아닙니다. –