Ignasi
Ignasi

Reputation: 6185

Spring aspectj implications

I'm working on a project which has an aspect and has a @EnableAspectJ on a configuration.

It means all proxies of spring are created using aspectj? What happen then with @Transactional and @Async? Should it has mode attribute set to use aspectJ ? Or it will uses CGLIB and Aspectj?

Upvotes: 1

Views: 187

Answers (1)

Ammar
Ammar

Reputation: 4024

From docs you need to set proxyTargetClass=true to use CGLIB proxies else standard JDK interface based proxies will be used.

Users can control the type of proxy that gets created for FooService using the proxyTargetClass() attribute. The following enables CGLIB-style 'subclass' proxies as opposed to the default interface-based JDK proxy approach.

 @Configuration
 @EnableAspectJAutoProxy(proxyTargetClass=true)
 public class AppConfig {
   // ...
 }

Upvotes: 2

Related Questions