AOP的三种实现

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> 

猜你喜欢

转载自pcpig.iteye.com/blog/2317750