Why jcabi-aspects annotations doesn't work

坚强是说给别人听的谎言 提交于 2021-01-29 07:50:47

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!