I've decided to write yet another question in this topic, as no solution from other posts worked for me.
My problem is that eclipse is unable to locate org.junit
package at all, even though it is available in Maven dependencies and all necessary classes can be seen after expanding junit-4.12.jar
.
Some technical info about the project and the environment:
Here's what I've already tried:
<?xml version="1.0" encoding="UTF-8"?>
<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>my-group-id</groupId>
<artifactId>my-artifact-id</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>my-name</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>9</source>
<target>9</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.10.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.10.0</version>
</dependency>
</dependencies>
<modules>
<module>module.1</module>
<module>module.2</module>
<module>module.3</module>
<module>module.4</module>
<module>module.5</module>
<module>module.6</module>
<module>module.7</module>
</modules>
</project>
...and subproject's POM looks like this:
<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>my-group-id</groupId>
<artifactId>my-artifact-id</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>module.4</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>my-module-4-name</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
As seen on the screenshot, the class is in the correct folder (src/test/java), so it's not a scope problem.
Maven > Update Project...
launched from eclipse for all projects (multiple times).sourceDirectory
element defined in any of my pom.xml files.I think it's also worth mentioning, that:
Running mvn test
results in:
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
java.lang.Exception: No runnable methods
, which is expected, as @Test
annotation isn't resolved.mvn verify
results in BUILD SUCCESS
.import org.apache.logging.log4j.core.Logger
, so it's not a JUnit problem.My workspace projects had the same problem identifying junit and other libraries after upgrading to Eclipse Photon. What worked for me was Maven > Update Project (you can select all open projects that has the issue). My projects were all in Java 8.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With