Using spring’s annotation method to implement AOP instances

Spring provides good support for the implementation of AOP. Let's use spring annotations to complete AOP as an example.

First, in order to use spring's AOP annotation function, you must import the following packages. aspectjrt. jar,aspectjweaver. jar,cglib-nodep. jar. Then we write an interface

And an interface implementation class

Next, use the spring annotation method to intercept this bean

This sentence is the method entry point. Execution means execution, * stands for any return value, followed by the package name* It means all sub packages under the package. (..) Represents various methods. Then the following annotation is relatively simple, that is, before and during the use of the method, there is surround interception /, and then continue to configure the bean in the spring configuration file. You need to open the AOP namespace

Then build a JUnit test

The test result is

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>