IntelliJ IDEA "Cannot resolve method" on aspect-defined method

5.6k Views Asked by At

I am using spring-data-neo4j 3.4.2, which is (optionally) using AspectJ.

My IDE is IntelliJ IDEA 16 (EAP, IU-144.3891.8). I have had the same problem using latest IntelliJ IDEA 15.

Everything works fine so far within IntelliJ, I can compile, run my Unit-Tests, deploy and run my web-application to/on Wildfly and so on.

When building my project in IntelliJ, I can see usage of the required aspects (the following warning is ok).

org.springframework.data.neo4j.aspects.support.node.Neo4jNodeBacking has not been applied [Xlint:adviceDidNotMatch]
...

My problem: IntelliJ IDEA uses the spring-aspects/ajc correctly. But in the editor, the aspects are not resolved/used. Code-completion etc. does not work.

IntelliJ editor error message

At AspectJ-facet configuration, aspect-path is configured as suggested.

AspectJ facet configuration.

Plugins "AspectJ Support" and "Spring AOP/@AspectJ" are installed and active.

installed aspectj plugin

I would like to use the spring-(data-)aspects in my editor, any suggestions, how IntelliJ Editor can get aware of the apsects?

4

There are 4 best solutions below

0
On

From pom.xml remove the <runtime> tag from the dependency of aspectjweaver and aspectjrt and compile the pom.xml file.

<dependency>
    <groupId>org.aspectj</groupId>
    <artifactId>aspectjrt</artifactId>
    <version>1.9.7</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.aspectj/aspectjweaver -->
<dependency>
    <groupId>org.aspectj</groupId>
    <artifactId>aspectjweaver</artifactId>
    <version>1.9.7</version>
</dependency>
1
On

There are a lot of open AspectJ-related tickets for IDEA. They have not been resolved for a long time. I love IDEA, but when it comes to AspectJ support Eclipse is superior, probably because AspectJ is an Eclipse project. So whenever I am dealing with AspectJ, I normally use Eclipse, as much as I would like to do everything in my favourite IDE IntelliJ IDEA.

0
On

Go to project structure -> Dependencies -> and then make all dependencies compile time.

0
On

I resolved this issue by adding the following maven dependency. None of solutions worked for me which were given here. Another solution is here.

Maven Dependency:

<!-- https://mvnrepository.com/artifact/org.springframework/spring-aspects -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-aspects</artifactId>
        <version>3.2.0.RELEASE</version>
    </dependency>

Hope this fix will help other users too.