Spring first essays

A: spring configuration file, that does not necessarily have to write XML file can also be configured through configuration files related categories

   Although both are configured using annotations in the code class-based annotation SpringAop, but it's still ApplicationContext.xml will use the following two configuration

                         <context:component-scan base-package="com.abc.test8.myThree"></context:component-scan>
                         <aop:aspectj-autoproxy/>

 And, we are all configured in ApplicationContext.xml SpringAop XML-based configuration

And based on the profile class, are configured in the class, no XML file

 

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;

@Configuration
@ComponentScan("com")//等同于<context:component-scan base-package="com.abc.test8.myThree"></context:component-scan>
@EnableAspectJAutoProxy//等同于 <aop:aspectj-autoproxy/>
public class AppConfig {
}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Want to do advanced development, these have to study

    阅读 SpringAop 文档
@execution: For matching method execution join points. This is the primary pointcut designator to use when working with Spring AOP. @within: Limits matching to join points within certain types (the execution of a method declared within a matching type when using Spring AOP). @
this: Limits matching to join points (the execution of methods when using Spring AOP) where the bean reference (Spring AOP proxy) is an instance of the given type. @target: Limits matching to join points (the execution of methods when using Spring AOP) where the target object (application object being proxied) is an instance of the given type. @args: Limits matching to join points (the execution of methods when using Spring AOP) where the arguments are instances of the given types. @target: Limits matching to join points (the execution of methods when using Spring AOP) where the class of the executing object has an annotation of the given type. @args: Limits matching to join points (the execution of methods when using Spring AOP) where the runtime type of the actual arguments passed have annotations of the given types. @within: Limits matching to join points within types that have the given annotation (the execution of methods declared in types with the given annotation when using Spring AOP). @annotation: Limits matching to join points where the subject of the join point (the method being executed in Spring AOP) has the given annotation.

 

Guess you like

Origin www.cnblogs.com/lcj12121/p/11408075.html