Nie jestem pewien, co się dzieje, ale AOP po prostu nie działa w moim setupie z wiosennym bootowaniem (v1.1.6).Spring Boot Czas ładowania AOP
@Configuration
@ComponentScan
@EnableJpaRepositories
@EnableTransactionManagement
@EnableAutoConfiguration
@EnableCaching
@EnableLoadTimeWeaving
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
A w klasie obrazu
@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");
}
}
w klasie usług, który potrzebuje porady
@Service
public class MyService {
public void test(String str1, String str2) throws IOException {
System.out.println("Test method in service");
//rest of the implementation
}
}
Mam też META-INF/aop.xml Podobnie jak
<!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>
Po uruchomieniu aplikacji z opcją -ja vaagent: ścieżka/do/wiosna-Instrument-4.1.0.RELEASE.jar
dostaję ten komunikat na konsoli
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]
nic się nie dzieje z radą chociaż. Nie wystrzeli.
Czy robię coś nie tak?