I am trying to set up Spring AOP without any XML and wonder how to enable auto-proxying this way.
Defining an AutoProxyCreator-bean works, but isn't there an easier way?
This is what my @Configuration looks like:
@Configuration
public class Context {
@Bean
public AnnotationAwareAspectJAutoProxyCreator annotationAwareAspectJAutoProxyCreator() {
return new AnnotationAwareAspectJAutoProxyCreator();
};
...
}
All other beans are scanned in by AnnotationConfigApplicationContext
.
Spring 3.0.x doesn't provide easy ways to replace XML namespace extensions (such as <aop:aspectj-autoproxy>
) in @Configuration
.
An upcoming Spring 3.1 will support special annotations for this purpose, such as @EnableAspectJAutoProxy
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With