码迷,mamicode.com
首页 > 编程语言 > 详细

Spring 第一 随笔集

时间:2019-08-25 15:51:01      阅读:74      评论:0      收藏:0      [点我收藏+]

标签:instance   one   sub   enable   aop   auto   mat   types   matching   

一: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 第一 随笔集

标签:instance   one   sub   enable   aop   auto   mat   types   matching   

原文地址:https://www.cnblogs.com/lcj12121/p/11408075.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!