Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/sarakhild/spring-boot-aop

This project simplify the Spring AOP
https://github.com/sarakhild/spring-boot-aop

java spring-aop spring-aop-annotation spring-boot

Last synced: about 2 months ago
JSON representation

This project simplify the Spring AOP

Awesome Lists containing this project

README

        

# Spring Boot Aop Project


## Overview
In this project I implement an Aspect for logging execution for service, controller, and repository Spring components using Spring AOP




## Usages
- SpringBoot
- Spring AOP
- Lombok
- MySQL


## Architecture of the Project

### 1-src folder

- Aspect
- Exception
- Controller
- Model
- Service
- Repository

### 2-Maven pom.xml




```


org.springframework.boot
spring-boot-starter-data-jpa


org.springframework.boot
spring-boot-starter-web


com.mysql
mysql-connector-j
runtime


org.projectlombok
lombok
true


org.springframework.boot
spring-boot-starter-test
test


org.springframework.boot
spring-boot-starter-aop


```




### 3-Application.Properties

```
spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql://localhost:3312/db
spring.datasource.username=db
spring.datasource.password=nFLhPPKOnkW1FA1e
spring.jpa.show-sql=true

```
## Let's Start :mechanical_arm:

##### :pencil2: `Pointcut that matches all repositories, services, and Web REST endpoints. Method is empty as this is just a Pointcut, the implementations are in the Before advices. The second Before that matche with create employee method with 0 or many args, employee type that match with advice args. The AfterReturning is executed after a join point completes normally, for example, if the method returns without throwing an exception.`

###### Code :computer:


![](https://github.com/SaraKhild/spring-boot-aop/assets/67427643/5932b9b1-1862-40a0-88a9-f5f27c0388a8)


###### Result :star_struck:


![](https://github.com/SaraKhild/spring-boot-aop/assets/67427643/c0baa5e3-57f4-4a7d-add7-ee8d4e422a61)

---


##### :pencil2: `Pointcut that matches all repositories, services, and Web REST endpoints. Method is empty as this is just a Pointcut, the implementations are in the Before advices. Around that matches all methods service which logs when a method is entered and exited.`

###### Code :computer:


![](https://github.com/SaraKhild/spring-boot-aop/assets/67427643/a3d4a7b2-18d7-4f65-a89a-dc4e49c16f2c)

![](https://github.com/SaraKhild/spring-boot-aop/assets/67427643/ceb208a9-ff27-4245-b40a-f884ff15ddc1)


###### Result :star_struck:


![](https://github.com/SaraKhild/spring-boot-aop/assets/67427643/f9c6f29c-407d-406f-956a-88c399eef8e1)

---


##### :pencil2: `Pointcut that matches all repositories, services, and Web REST endpoints. Method is empty as this is just a Pointcut, the implementations are in the Before advices. Around that matches all methods service which logs when a method is entered and when throwing exception.`

###### Code :computer:


![](https://github.com/SaraKhild/spring-boot-aop/assets/67427643/519a3c41-b03f-4cd6-b868-79acd31df43e)

![](https://github.com/SaraKhild/spring-boot-aop/assets/67427643/2fe6dba5-6fcb-4c5b-be66-33008cbc9b32)


###### Result :star_struck:


![IMG_1711](https://github.com/SaraKhild/spring-boot-aop/assets/67427643/39f57424-3faa-402b-8e09-ae20bec4e780)

---

### Good Luck