2014-09-05 7 views
5

무엇이 잘못되었지만 스프링 부트 (v1.1.6)로 설정에서 AOP가 작동하지 않는 것 같지 않습니다. 스프링 부트 AOP 로딩 시간

@Configuration 
@ComponentScan 
@EnableJpaRepositories 
@EnableTransactionManagement 
@EnableAutoConfiguration 
@EnableCaching 
@EnableLoadTimeWeaving 
public class Application { 
    public static void main(String[] args) { 
     SpringApplication.run(Application.class, args); 
    } 
} 

그리고 조언

@Service 
public class MyService { 
    public void test(String str1, String str2) throws IOException { 
    System.out.println("Test method in service"); 
    //rest of the implementation 
    } 
} 

을 필요로하는 서비스 클래스에서 가로 세로 클래스

@Aspect 
public class MyAspect { 
    @AfterReturning(pointcut = "execution(private * com.myapp.service.MyService.test(..)) && args(str1,str2)", argNames = "str1,str2") 
    public void advice(String str1, String str2) throws IOException { 
     System.out.println("Advising after returning"); 
    } 
} 

에서

은 또한 너무

같은 META-INF는/aop.xml이
<!DOCTYPE aspectj PUBLIC "-//AspectJ//DTD//EN" "http://www.eclipse.org/aspectj/dtd/aspectj.dtd"> 
<aspectj> 
    <weaver> 
     <!-- only weave classes in our application-specific packages --> 
     <include within="com.myapp.*"/> 
    </weaver> 

    <aspects> 
     <!-- weave in just this aspect --> 
     <aspect name="com.myapp.aspect.MyAspect"/> 
    </aspects> 

</aspectj> 

-ja로 응용 프로그램을 실행할 때 vaagent : 경로// 스프링 악기 4.1.0.RELEASE.jar

에 내가

2014-09-05 08:42:12.500 INFO 65053 --- [   main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 
[[email protected]] warning javax.* types are not being woven because the weaver option '-Xset:weaveJavaxPackages=true' has not been specified 
2014-09-05 08:42:13.114 INFO 65053 --- [   main] o.s.j.e.a.AnnotationMBeanExporter  : Registering beans for JMX exposure on startup 
2014-09-05 08:42:13.156 INFO 65053 --- [   main] o.s.b.a.e.jmx.EndpointMBeanExporter  : Registering beans for JMX exposure on startup 
[[email protected]] error can't determine implemented interfaces of missing type org.springframework.security.config.http.SessionCreationPolicy 
when weaving type org.springframework.boot.actuate.autoconfigure.ManagementServerProperties$Security 
when weaving classes 
when weaving 
[Xlint:cantFindType] 
[[email protected]] error can't determine implemented interfaces of missing type org.springframework.security.config.http.SessionCreationPolicy 
when weaving type org.springframework.boot.actuate.autoconfigure.ManagementServerProperties$Security 
when weaving classes 
when weaving 
[Xlint:cantFindType] 

아무것도 비록 조언 발생하지 콘솔에이 메시지가 표시됩니다. 그것은 발사되지 않습니다.

내가 잘못 했나요?

당신이 특권 측면 사용해야 개인 방법을 조언하기 위해

답변

0

:

public privileged aspect MyAspect { 
    // ... 
} 

을하지만 AspectJ documentation는 말한다 :

이 제한 : 권한 측면에서 지원되지 않습니다 주석 스타일.

@AspectJ 스타일이 아닌 기본 구문을 사용하십시오. 하지만 그렇게하기 전에, 권한이 부여되지 않은 주석 스타일의 측면이 공용 메서드를 사용하여 예상대로 작동하는지 확인하여 다른 측면이 얽히게되지 않도록하십시오.