본문 바로가기
백엔드/Java

Spring AOP

by david100gom 2024. 3. 20.

Spring AOP 는 static method 에서는 작동을 안한다.

Subject line basically says it all. I have a static method I want to intercept so that around advice can be applied to it. I can get this to work with any non-static methods but I'm unsure how to allow static methods to be intercepted.
-->
You can't do that with Spring AOP, because it is proxy based. You have to use AspectJ. Take a look at this simple example: http://blog.jayway.com/2007/02/16/static-mock-using-aspectj/

댓글