问题
I have this code:
public static void main(String[] args)
{
testAnnotation();
}
@RetryOnFailure(attempts = 2)
public static void testAnnotation() {
System.out.println("enter here");
int x = 1/0;
}
But it runs the function just one time. This is the output:
enter here
Exception in thread "main" java.lang.ArithmeticException: / by zero
at Main.testAnnotation(Main.java:16)
at Main.main(Main.java:10)
This my pom:
<dependency>
<groupId>com.jcabi</groupId>
<artifactId>jcabi-aspects</artifactId>
<version>0.22.6</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.9.2</version>
<scope>runtime</scope>
</dependency>
Plus this plugin:
<plugin>
<groupId>com.jcabi</groupId>
<artifactId>jcabi-maven-plugin</artifactId>
<version>0.14.1</version>
<executions>
<execution>
<goals>
<goal>ajc</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>1.9.2</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.9.2</version>
</dependency>
</dependencies>
</plugin>
My program doesn't recognize any annotation not just the retry. How can I make it recognize the annotations? thank you
来源:https://stackoverflow.com/questions/64537064/why-jcabi-aspects-annotations-doesnt-work