欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

AOP的三种实现

程序员文章站 2022-07-09 13:47:03
...
1、利用Spring AOP
2、所依赖的包是普通java编译,非aspectJ编译
<!-- 编译加强 -->
	<plugin>
		<groupId>org.codehaus.mojo</groupId>
		<artifactId>aspectj-maven-plugin</artifactId>
		<version>1.8</version>
		<executions>
			<execution>
				<goals>
					<goal>compile</goal>
					<goal>test-compile</goal>
				</goals>

				<configuration>
					<complianceLevel>1.7</complianceLevel>
					<source>1.7</source>
					<target>1.7</target>			
                    <weaveDependencies>
                        <weaveDependency>
                            <groupId>xx</groupId>
                            <artifactId>yy</artifactId>
                        </weaveDependency>
                    </weaveDependencies>
				</configuration>
			</execution>
		</executions>
	</plugin> 


3、所依赖的包用aspectJ编译过
	    <plugin>
		        <groupId>org.codehaus.mojo</groupId>
		        <artifactId>aspectj-maven-plugin</artifactId>
		        <version>1.8</version>
		        <executions>
		            <execution>
		                <goals>
		                    <goal>compile</goal>
		                    <goal>test-compile</goal>
		                </goals>
		
		                <configuration>
		                    <complianceLevel>1.7</complianceLevel>
		                    <source>1.7</source>
		                    <target>1.7</target>
		                    <aspectLibraries>
		                        <aspectLibrary>
		                            <groupId>XX</groupId>
		                            <artifactId>YY</artifactId>
		                            <classifier>aspectj</classifier>
		                        </aspectLibrary>                        
		                    </aspectLibraries>
		                </configuration>
		            </execution>
		        </executions>
		    </plugin> 
相关标签: aop