(aspect oriented programming面向切面编程)
首先在原有的jar包:
需Spring压缩包中的四个核心JAR包
beans 、context、core 和expression
下载地址:
https://pan.baidu.com/s/1qXLHzAW
以及日志jar包
commons-logging 和log4j
下载地址:
https://pan.baidu.com/s/1mimTW5i
再增加一个
spring-aop-5.0.1.RELEASE.jar (用于注解,在Spring-framework库中包含)
再增加
spring-aspects-5.0.1.RELEASE.jar (在Spring-framework库中包含)
aspectjweaver-1.8.12.jar (官方下载地址 http://mvnrepository.com/artifact/org.aspectj/aspectjweaver)
spring收购的aspectj的一部分包只关于weaver的
aopalliance-1.0.jar (官方下载地址 http://mvnrepository.com/artifact/aopalliance/aopalliance/1.0)
上边是aop联盟的包
然后在Spring-framework库中docs文件夹中找到html文件夹的xsd-configuration.html文件
找到aop的相关约束。(不包含注解的约束)
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> <!-- bean definitions here --> </beans>
之前的注解context的约束(包括了下边的beans的约束)
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <!-- bean definitions here --> </beans>
之前的beans的约束
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean id="foo" class="x.y.Foo"> <property name="name" value="Rick"/> </bean> </beans>
包含beans 注解context 和aop的约束
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> <!-- 开启注解扫描 --> <context:component-scan base-package="com.swift"></context:component-scan> </beans>
来源:https://www.cnblogs.com/qingyundian/p/7868001.html