Spring 第一 随笔集

Posted lcj12121

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Spring 第一 随笔集相关的知识,希望对你有一定的参考价值。

一:spring的配置文件,即XML文件不需要必须写,也可以通过配置文件类进行相关配置

   基于注解的SpringAop,虽然都使用注解在代码类中进行配置,但是它的ApplicationContext.xml还是会用到下面这两个配置

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

 而基于XML配置的SpringAop,则全部都是在ApplicationContext.xml中进行配置

而基于配置文件类,则都在类中配置,不需要XML文件

 

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 


 

 

 

 

 

 

 

 

 

 

 

 

 

 

想做高级开发,这些都要去研究

    阅读 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.

 

以上是关于Spring 第一 随笔集的主要内容,如果未能解决你的问题,请参考以下文章

第一篇随笔__原创

第一次写随笔

第一次的Java随笔

第一次随笔

python,第一次课堂随笔

第一次随笔