The configuration process can be easily divided into 3 steps:
1, Business class configuration
Join before the business class and leave the business class to spring management
@Component ("s")
This indicates that the bean name of this business class is S.
2, associating tangency and tangent classes
Put two sentences in front of the slicing class
@Aspect annotations indicate that this is a facet
@Component says this is a bean, managed by spring
In addition to the specific method of the slice class, it means that when the pointcut is triggered, the function is executed in the around manner, which is equivalent to associating the tangent point with the processing method of the tangent line.
The @Around (value = "Execution (* com.how2java.service.productservice.* (..))") represents the Com.how2java.service.ProductService All methods in this class are tangent
The implication is that when a function in expression is called, the tangent function is triggered in the form of around, which precedes who is defined as the tangent function, which is the accessibility function.
3, add some content to the XML:
<base-package= "Com.how2java.aspect"/>< Base-package= "Com.how2java.service"/> Scan packages Com.how2java.aspect and Com.how2java.service, locate business classes and slice classes
< Aop:aspectj-autoproxy />
Find the annotated slice class, and make a slice configuration
Annotated configuration of Spring's AOP