I created a pom.xml that includes the XML to import JUnit 4. I opened up project in IntelliJ. It seems to have downloaded the external dependency, but when I try to use the dependency in an import statement, IntelliJ can't recognize it.
Here are the steps I took from the beginning:
- I created a pom.xml.
- mkdir MAVEN
- mv pom.xml MAVEN
- Open IntelliJ
- File > open > pom.xml
- cd ~/MAVEN
- mkdir -p src/main/java
- Go back to IntelliJ
- Right click on src -> mark directory as root
I believe that Maven imported everything correctly because I can see JUnit as a dependency in the project directory: https://imgur.com/TdJq7PK
Here is my pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.company.org</groupId>
<artifactId>mvn-prac</atifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
When I attempt to use a common class from JUnit, such as import org.junit.Test;
, IntelliJ can't recognize the symbol.
I have attempted both mvn clean
and mvn install
in the root of the project, and neither seemed to help.
Thanks for any help.