<parent> <groupId>org.apache.commons</groupId> <artifactId>commons-weaver-parent</artifactId> <version>1.1</version> </parent> <dependencies> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjrt</artifactId> <version>1.9.6</version> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>1.9.6</version> </dependency> </dependencies> import org.apache.commons.weaver.privilizer.Privilizing; @Privilizing("mode=get;class=com.example.MyClass") public aspect MyAspect { before() : execution(* com.example.MyClass.myMethod(..)) { System.out.println("Before method execution"); } after() : execution(* com.example.MyClass.myMethod(..)) { System.out.println("After method execution"); } } <build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>aspectj-maven-plugin</artifactId> <version>1.13.0</version> <configuration> <complianceLevel>1.8</complianceLevel> <source>1.8</source> <target>1.8</target> </configuration> <dependencies> <dependency> <groupId>${project.groupId}</groupId> <artifactId>${project.artifactId}</artifactId> <version>${project.version}</version> </dependency> </dependencies> <executions> <execution> <goals> <goal>compile</goal> <goal>test-compile</goal> </goals> </execution> </executions> </plugin> </plugins> </build>


上一篇:
下一篇:
切换中文