Similar to some other Questions, I find IntelliJ mysteriously refuses to recognize AssertJ library. I am asking again as (a) I have tried the various suggestions, and (b) I have a very simple example anyone can try themselves.
In IntelliJ 2018 and IntelliJ 2019 pre-release, I create a new project using the Maven archetype maven-archetype-quickstart
version 1.4.
AssertJ 3 requires Java 8. So I changed these two lines in the POM for 1.7
to 11
.
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
I add this to the POM:
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.11.1</version>
<scope>test</scope>
</dependency>
Using the Maven panel in IntelliJ, I executed a clean
and install
.
Seems good. I verify the org.assertj:assertj-core:3.11.1
library appears in the Project panel of IntelliJ. The app runs, with Hello World appearing on the console in IntelliJ.
In the App.java
file, I add this import
statement.
import static org.assertj.core.api.Assertions.* ;
Error reported in the IDE editor:
Cannot resolve symbol 'Assertions'
Some people suggest a corrupted Maven cache. So I quit IntelliJ, and I delete the .m2
folder in my home folder. I re-open my project in IntelliJ, and re-execute the Maven clean
& install
. Many things are downloading, so I know the Maven cache is indeed being recreated.
Yet, still the error in my editor, Cannot resolve symbol 'Assertions'
.
No Java Modules involved, as the quickstart
archetype has not yet been updated for that.