Ich versuche, einen Rat einer Methode eines Projekts (test5) zu erstellen, die von einem anderen Projekt (testMaven) aufgerufen wird. Ich habe das Projekt test5 bereits als Abhängigkeit in testMavens pom.xml aufgenommen und einen Hinweis in testMavens Klasse eingerichtet, aber es wird trotzdem nicht ausgeführt. Der Aufruf der Methode (dfg) funktioniert einwandfrei.Advice AspectJ ein Methodenaufruf von verschiedenen Maven-Projekt
Hier sind die Code dafür:
MainApp.java (testMaven)
package testMaven;
import test5.yxc;
public class MainApp {
public static void main(String[] args) {
yxc b = new yxc();
b.dfg(2);
}
}
yxc.java (test5)
package test5;
public class yxc {
public void dfg(int a){
System.out.println(a);
}
}
testAspect.java (testMaven)
package testMaven;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.annotation.Before;
import test5.yxc;
@Aspect
public class testAspect {
@Before("execution(* test5.yxc.dfg(..))")
public void testBefore(){
System.out.println("yooi");
}
}
pom.xml (tes tMaven)
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>testingMaven</groupId>
<artifactId>testMaven</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<spring.version>4.2.5.RELEASE</spring.version>
<java.version>1.8</java.version>
<!-- Maven Plugin Versions -->
<maven.compiler.plugin.version>3.2</maven.compiler.plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.8.9</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.8.9</version>
</dependency>
<dependency>
<groupId>test5</groupId>
<artifactId>test5</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.8</version>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.plugin.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Können Sie mir helfen, was ist los damit? Dank
es immer noch nicht gibt mir den Rat, Ihren Rat auf Plugin (btw habe ich nicht verwenden der Ausführungsteil, da es einen Fehler mit der tools.jar gibt, der versucht es zu beheben, aber immer noch kein Glück) –
Siehst du den aspectj Compiler etwas tun und Logeinträge wie oben erwähnt anzeigen? – uniknow
nein es gibt nichts wie du oben erwähnt –