There is a way to use execution when specifying a method in Spring and AOP. At that time, it is easy to write execution, so I will summarize it as a memorandum.
For example, if you have the following test method:
package test;
public class TestC {
public String testM(String str) throws Exception {
return "test";
}
}
When using pre-processing AOP for this test method, write as follows.
@Before("execution(public String test.TestC.testM(String)) throws Exception")
Write the elements in the following order. --Modifier --Return type
Qualifiers and exceptions can be omitted in this. Therefore, it is possible to write as follows.
@Before("execution(String test.TestC.testM(String))")
In addition, you can use wildcards in the return value, package name, and class name.
@Before("execution(* test.*.*(..))")
I always forget it, so it's worth it just to be able to remember it all together.
Recommended Posts