Không chắc chắn những gì đang xảy ra, nhưng AOP dường như không hoạt động trong thiết lập của tôi với khởi động mùa xuân (v1.1.6).Khởi động mùa xuân Thời gian tải AOP dệt
@Configuration
@ComponentScan
@EnableJpaRepositories
@EnableTransactionManagement
@EnableAutoConfiguration
@EnableCaching
@EnableLoadTimeWeaving
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
Và trong lớp khía cạnh
@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");
}
}
Trong lớp dịch vụ mà cần những lời khuyên
@Service
public class MyService {
public void test(String str1, String str2) throws IOException {
System.out.println("Test method in service");
//rest of the implementation
}
}
Tôi cũng có một META-INF/aop.xml như vậy
<!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>
Khi tôi chạy ứng dụng bằng -ja vaagent: path/to/mùa xuân-instrument-4.1.0.RELEASE.jar
tôi nhận được thông báo này trên console
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]
Không có gì xảy ra với những lời khuyên mặc dù. Nó sẽ không cháy.
Tôi có làm gì sai không?