So, I am working with Spring boot aop
used implementation 'org.springframework.boot:spring-boot-starter-aop'
in build.gradle
Issue:
I added @LogMetrics
annotation in following functions
@LogMetrics
public Employee createEmployee(String name, String empId)
@LogMetrics
public Employee oneparam(String a) {}
@LogMetrics
public Employee twoparam(String a, String b) {}
@LogMetrics
public Employee threeparam(String a, String b, String c) {}
but advice is not printing as per my requirement. It is only printing for createEmployee function
I used
@Before(value = "@annotation(com.paradox.springsample.annotations.LogMetrics) || within(com.paradox.springsample.annotations.LogMetrics)")
Can someone help me explain why the logs are not getting printed for above functions ? Is something wrong in my code or any implementation detail i am missing out Intellij was able to detect advice methods though
curl used::
curl -X GET 'http://localhost:9000/employee/add?name=rajat&empId=123'
Github url for code: https://github.com/rajat19/spring-aop-issue You can clone the repo and test it out. I can explain more on this if someone wants to test and check
Things I tried-
- adding
args(a, b)
etc. to distinguish functions inside @Before - making return type same for all functions
- using
execution(* com.paradox.springsample.services.EmployeeService.*(..))