CKuck CKuck - 6 months ago 125
Java Question

Spring AOP without XML

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:

public class Context {
public AnnotationAwareAspectJAutoProxyCreator annotationAwareAspectJAutoProxyCreator() {
return new AnnotationAwareAspectJAutoProxyCreator();

All other beans are scanned in by


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.