This is a simple spring boot application that implements Spring AOP
- Aspect Oriented Programming (AOP) compliments OOPs in the sense that it also provides modularity.
- AOP breaks the program logic into distinct parts (called concerns). It is used to increase modularity by cross-cutting concerns.
Spring AOP can be used in three different manners.
- By Spring1.2 Old style (dtd based) (also supported in Spring3)
- By AspectJ annotation-style
- By Spring XML configuration-style(schema-based)
But the most widely used approach is Spring AspectJ Annotation Style. This example implements using AspectJ annotation-style.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
- Create Spring Boot Project
- Add Spring AOP maven dependency
- Write aspect class annotated with @Aspect annotaction
- Write methods on which you want to execute advices
- Run the application and watch the console
To run this project, you need to install;
- Java 8
- IDE like InteliJ idea
curl --location 'http://localhost:8080/api/v1/users'
https://medium.com/@toimrank/spring-boot-aop-with-example-a2757e389d0b
https://www.edureka.co/blog/spring-aop-tutorial/
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.