org.aspectj.lang.NoAspectBoundException - method <

2019-07-20 12:59发布

问题:

I had same problem as vanhre asked in Spring forum, but in my case I couldn't change the constructor.

I'm using Spring java configuration, so it was initializing ok during jetty start, but in runtime, when I executed the functionality with my aspect it failed with exactly the same exception from the forum.

回答1:

I found later, that I need aspectjrt dependency in my pom.

<dependency>
    <groupId>org.aspectj</groupId>
    <artifactId>aspectjrt</artifactId>
    <version>1.6.12</version>
</dependency>

edit: Missing dependency was an error, but real problem is Eclipse + aspects combination. When I used Eclipse to build my aspect class this error occurred. Additionally when I compiled class the aspect advice was for, aspect was not called.

solution: you have to use maven to build your application (I'd be glad if someone find solution for Eclipse, because I'm sure I'll forget this)



回答2:

download http://central.maven.org/maven2/org/aspectj/aspectjrt/1.6.9/aspectjrt-1.6.9.jar and add to your project