How to intercept static methods in Spring?

混江龙づ霸主 提交于 2019-11-27 23:41:14

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/

See PowerMock https://github.com/powermock/powermock it can mock static methods

Taken from the blog post comment from LIMC's answer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!