I am receiving below compilation error while building Spring Boot application in a build env. However I don't see any error while running Junit test or building(package) it locally on my machine -
src/main/java/com/abc/tests/AbcTest.java : package org.junit does not exist
Here is my pom.xml -
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
<relativePath />
</parent>
<dependencies>........
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Here are the Steps i tried with no success -
1. placing explicit dependency on junit 4.12 as well as [4.12] in dependency section.
<dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency>
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <junitArtifactName> junit:junit:4.12</junitArtifactName> </configuration> </plugin>
Is there any other way to force the build process to use 4.12 junit version within pom.xml instead of picking some old version like 3.8 ?
Thanks
You have put your test inside the main/java
instead of test/java
: src/main/java/com/abc/tests/AbcTest.java
The Junit dependency has the <scope>test</scope>
so it is only visible to sources inside the test/java
during the build time.
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