liveBook · Manning

@EnableAspectJAutoProxy annotation

As explained in Spring Start Here, Second Edition

The @EnableAspectJAutoProxy annotation enables Spring's automatic proxy creation for AspectJ-style aspects.

@EnableAspectJAutoProxy turns on Spring’s aspect capability. Add it to a configuration class before registering an aspect bean and defining advice to intercept method calls. section 6.2.1

Listing 6.5 Enabling the aspects mechanism in a Spring app
@Configuration
@ComponentScan(basePackages = "com.example.services")
@EnableAspectJAutoProxy   #A
public class ProjectConfig {
}

See the annotation on ProjectConfig, alongside component scanning. section 6.2.1

Logging around a service call

With aspect support enabled, an around advice can log before and after CommentService.publishComment executes. section 6.2.1

How Spring Start Here, Second Edition covers it

How deep it goes
Shows where to place the annotation as the first setup step, but does not explain proxy-creation internals.
Examples
Uses ProjectConfig to enable an around-logging aspect for CommentService.publishComment.
What it assumes
Assumes a Spring configuration class and introduces aspect enablement before defining an aspect bean and advice.
What you can do after
Configure aspect support by annotating a Spring configuration class with @EnableAspectJAutoProxy.
How it connects
Connects Spring AOP with aspects, advice, pointcuts, and intercepted service methods.

This explainer was generated by Manning's knowledge graph from the text of Spring Start Here, Second Edition. The section links point to the parts of the book it draws on.