Maven: package io.swagger.annotations does not exist - java

I want to document my project with swagger. I add swagger annotations and io.springfox dependencies to my project but when I run mvn clean package I have a lot of errors:
PS D:\parent-project> mvn clean package
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] parent-project [pom]
[INFO] module-common-lib [jar]
[INFO] module1 [jar]
[INFO] module2 [jar]
[INFO]
[INFO] ------------< parent-project:parent-project >-------------
[INFO] Building parent-project 0.0.1-SNAPSHOT [1/4]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # parent-project ---
[INFO]
[INFO] -------< parent-project:module-common-lib >-------
[INFO] Building module-common-lib 0.0.1-SNAPSHOT [2/4]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # module-common-lib ---
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) # module-common-lib ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\parent-project\module-common-lib\src\main\resources
[INFO] skip non existing resourceDirectory D:\parent-project\module-common-lib\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.6.1:compile (default-compile) # module-common-lib ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 4 source files to D:\parent-project\module-common-lib\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/ResponseInfo.java:[6,30] package io.swagger.annotations does not exist
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/ResponseInfo.java:[7,30] package io.swagger.annotations does not exist
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/ResponseInfo.java:[9,2] cannot find symbol
symbol: class ApiModel
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/HelloWorldResponse.java:[4,30] package io.swagger.annotations does not exist
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/HelloWorldResponse.java:[5,30] package io.swagger.annotations does not exist
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/ResponseSimple.java:[5,30] package io.swagger.annotations does not exist
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/ResponseSimple.java:[6,30] package io.swagger.annotations does not exist
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/ResponseSimple.java:[8,2] cannot find symbol
symbol: class ApiModel
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/HelloWorldResponse.java:[7,2] cannot find symbol
symbol: class ApiModel
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/HelloWorldMessageResponse.java:[4,30] package io.swagger.annotations does not exist
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/HelloWorldMessageResponse.java:[5,30] package io.swagger.annotations does not exist
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/HelloWorldMessageResponse.java:[7,2] cannot find symbol
symbol: class ApiModel
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/ResponseInfo.java:[31,10] cannot find symbol
symbol: class ApiModelProperty
location: class com.company.lab.microservices.common.api.ResponseInfo
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/ResponseInfo.java:[40,10] cannot find symbol
symbol: class ApiModelProperty
location: class com.company.lab.microservices.common.api.ResponseInfo
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/ResponseInfo.java:[49,10] cannot find symbol
symbol: class ApiModelProperty
location: class com.company.lab.microservices.common.api.ResponseInfo
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/HelloWorldResponse.java:[13,10] cannot find symbol
symbol: class ApiModelProperty
location: class com.company.lab.microservices.common.api.HelloWorldResponse
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/ResponseSimple.java:[13,10] cannot find symbol
symbol: class ApiModelProperty
location: class com.company.lab.microservices.common.api.ResponseSimple
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/HelloWorldMessageResponse.java:[14,10] cannot find symbol
symbol: class ApiModelProperty
location: class com.company.lab.microservices.common.api.HelloWorldMessageResponse
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/HelloWorldMessageResponse.java:[23,10] cannot find symbol
symbol: class ApiModelProperty
location: class com.company.lab.microservices.common.api.HelloWorldMessageResponse
[INFO] 19 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] parent-project 0.0.1-SNAPSHOT ............... SUCCESS [ 0.156 s]
[INFO] module-common-lib ................... FAILURE [ 1.530 s]
[INFO] module1 ..................... SKIPPED
[INFO] module2 0.0.1-SNAPSHOT ...... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.910 s
[INFO] Finished at: 2018-09-18T09:39:17+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:compile (default-compile) on project module-common-lib: Compilation failure: Compilation failure:
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/ResponseInfo.java:[6,30] package io.swagger.annotations does not exist
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/ResponseInfo.java:[7,30] package io.swagger.annotations does not exist
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/ResponseInfo.java:[9,2] cannot find symbol
[ERROR] symbol: class ApiModel
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/HelloWorldResponse.java:[4,30] package io.swagger.annotations does not exist
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/HelloWorldResponse.java:[5,30] package io.swagger.annotations does not exist
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/ResponseSimple.java:[5,30] package io.swagger.annotations does not exist
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/ResponseSimple.java:[6,30] package io.swagger.annotations does not exist
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/ResponseSimple.java:[8,2] cannot find symbol
[ERROR] symbol: class ApiModel
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/HelloWorldResponse.java:[7,2] cannot find symbol
[ERROR] symbol: class ApiModel
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/HelloWorldMessageResponse.java:[4,30] package io.swagger.annotations does not exist
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/HelloWorldMessageResponse.java:[5,30] package io.swagger.annotations does not exist
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/HelloWorldMessageResponse.java:[7,2] cannot find symbol
[ERROR] symbol: class ApiModel
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/ResponseInfo.java:[31,10] cannot find symbol
[ERROR] symbol: class ApiModelProperty
[ERROR] location: class com.company.lab.microservices.common.api.ResponseInfo
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/ResponseInfo.java:[40,10] cannot find symbol
[ERROR] symbol: class ApiModelProperty
[ERROR] location: class com.company.lab.microservices.common.api.ResponseInfo
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/ResponseInfo.java:[49,10] cannot find symbol
[ERROR] symbol: class ApiModelProperty
[ERROR] location: class com.company.lab.microservices.common.api.ResponseInfo
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/HelloWorldResponse.java:[13,10] cannot find symbol
[ERROR] symbol: class ApiModelProperty
[ERROR] location: class com.company.lab.microservices.common.api.HelloWorldResponse
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/ResponseSimple.java:[13,10] cannot find symbol
[ERROR] symbol: class ApiModelProperty
[ERROR] location: class com.company.lab.microservices.common.api.ResponseSimple
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/HelloWorldMessageResponse.java:[14,10] cannot find symbol
[ERROR] symbol: class ApiModelProperty
[ERROR] location: class com.company.lab.microservices.common.api.HelloWorldMessageResponse
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/HelloWorldMessageResponse.java:[23,10] cannot find symbol
[ERROR] symbol: class ApiModelProperty
[ERROR] location: class com.company.lab.microservices.common.api.HelloWorldMessageResponse
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :module-common-lib
In this project both module1 and module2 use the common-lib to use JSON as a response type and to create the documentation with swagger.
Structure Project:
parent-project
pom.xml
module-common-lib
pom.xml
src/main/java
module1
src/main/java
src/main/resources
pom.xml
module2
src/main/java
src/main/resources
pom.xml
Pom.xml - parent-project:
<?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">
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<packageClassifier>exec</packageClassifier>
<spring-boot.version>1.5.9.RELEASE</spring-boot.version>
<spring-cloud.version>1.4.4.RELEASE</spring-cloud.version>
<springfox-swagger.version>2.6.1</springfox-swagger.version>
</properties>
<dependencyManagement>
<dependencies>
.....
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>module-common-lib</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${springfox-swagger.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${springfox-swagger.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<finalName>${project.artifactId}</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.4.13</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
</plugins>
</build>
Pom.xml - module-common-lib
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
</dependency>
</dependencies>
</dependencyManagement>
</project>
One of the classes with swagger annotations (the other classes have the same annotations but diferent code):
import java.io.Serializable;
import java.util.Optional;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
#ApiModel
public class ResponseSimple implements Serializable {
transient private static final long serialVersionUID = 5106222175899418836L;
private ResponseInfo responseInfo = new ResponseInfo();
#ApiModelProperty(notes = "Response info")
public ResponseInfo getResponseInfo() {
return responseInfo;
}
public void setResponseInfo(ResponseInfo responseInfo) {
this.responseInfo = responseInfo;
}
#Override
public String toString() {
return Optional.of(responseInfo).map(ri -> ri.toString()).orElse("");
}
}
I have Maven 3.5.4
Does anyone know why it does not work?

In your module-common-lib/pom.xml file, you only refer to the io.springfix:springfox-swagger2 dependency in the <dependencyManagement> element.
In the child POM, the <dependencies> element does not need to be inside a <dependencyManagement> element, since you are consuming the dependency (not just managing its version, scope, exclusions and so on for subsequent consumption - which is what the parent POM does).
Basically the fact that the dependency io.springfox:springfox-swagger2 is only in the <dependencyManagement> section means that it (and, more importantly, also its transitive dependency io.swagger:swagger-annotations which contains the io.swagger.annotationspackage) is not added to the compilation classpath.
You can verify this by running mvn dependency:build-classpath to see the classpath that Maven builds.
The fix is to remove the lines <dependencyManagement> and </dependencyManagement> in module-common-lib/pom.xml (but NOT from parent-project/pom.xml, where the element serves its intended purpose).

Related

Cannot find classes from imported module during maven build

I am working on a module in a project that's to convert old data structure to match updated data structure. Since most of the methods and classes required for said conversion have already been implemented in a prior module in the same project, I added the prior module as a dependency in the new module.
It works, as I can access the required classes and their public methods. However, when I run 'mvn clean install' to build the new module, the new module's build fails with errors about not finding the imported classes.
Here is the parent pom file:
<?xml version="1.0" encoding="UTF-8"?>
<!--suppress MavenModelInspection -->
<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.hcb.migration.bioenrol</groupId>
<artifactId>hcb-migration-bienrol</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
<java.version>1.8</java.version>
<maven.compiler.version>3.8.0</maven.compiler.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.resourceEncoding>UTF-8</project.build.resourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<modules>
<module>abis-migrations-imports</module>
<module>abis-migrations-export</module>
<module>abis-migrations-conversion</module>
<module>runtime-migrations-export</module>
<module>runtime-migrations-conversion</module>
<module>runtime-migrations-import</module>
</modules>
<distributionManagement>
<snapshotRepository>
<!-- This repo requires credentials from your ~/.m2/settings.xml -->
<id>archiva-snapshot-repo</id>
<name>hcb-snapshot-repo</name>
<url>http://archiva.hcb:8080/repository/archiva-snapshot-repo/</url>
</snapshotRepository>
<repository>
<!-- This repo requires credentials from your ~/.m2/settings.xml -->
<id>archiva-release-repo</id>
<name>hcb-release-repo</name>
<url>http://archiva.hcb:8080/repository/archiva-release-repo/</url>
</repository>
</distributionManagement>
<repositories>
<repository>
<!-- This repo requires credentials from your ~/.m2/settings.xml -->
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>archiva-snapshot-repo</id>
<name>hcb-snapshot-repo</name>
<url>http://archiva.hcb:8080/repository/archiva-snapshot-repo/</url>
</repository>
<repository>
<!-- This repo requires credentials from your ~/.m2/settings.xml -->
<id>archiva-release-repo</id>
<name>hcb-release-repo</name>
<url>http://archiva.hcb:8080/repository/archiva-release-repo/</url>
</repository>
</repositories>
</project>
This is the pom file of the older module:
<?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">
<parent>
<artifactId>hcb-migration-bienrol</artifactId>
<groupId>com.hcb.migration.bioenrol</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
<artifactId>abis-migrations-conversion</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<!-- MMABIS client -->
<dependency>
<groupId>com.hcb.3rdparty.libs</groupId>
<artifactId>neurotec-abis-client-management-rest</artifactId>
<version>12.0.0.0</version>
</dependency>
<dependency>
<groupId>com.hcb.services.bioenroll</groupId>
<artifactId>bioenroll-inf</artifactId>
<version>1.0-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Add class with main method to manifest-->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.3.4.RELEASE</version>
<configuration>
<mainClass>com.hcb.neurotec.migrations.conversion.AbisExportConverter</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
This is the pom file of the module I am working on whose build fails:
<?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">
<parent>
<artifactId>hcb-migration-bienrol</artifactId>
<groupId>com.hcb.migration.bioenrol</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>runtime-migrations-conversion</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.hcb.migration.bioenrol</groupId>
<artifactId>abis-migrations-conversion</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.3.4.RELEASE</version>
<configuration>
<mainClass>com.hcb.runtime.migrations.conversion.RuntimeConversionApplication</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Here is the build error:
[INFO] 45 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.418 s
[INFO] Finished at: 2023-01-20T12:23:07+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project runtime-migrations-conversion: Compilation failure: Compilation failure:
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/pojo/RConversionSubInfo.java:[4,46] package com.hcb.neurotec.migrations.conversion does not exist
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/pojo/RConversionSubInfo.java:[5,46] package com.hcb.neurotec.migrations.conversion does not exist
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/pojo/RConversionSubInfo.java:[6,46] package com.hcb.neurotec.migrations.conversion does not exist
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/pojo/RConversionSubInfo.java:[7,46] package com.hcb.neurotec.migrations.conversion does not exist
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/pojo/RConversionSubInfo.java:[8,56] package com.hcb.neurotec.migrations.conversion.exception does not exist
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/pojo/RConversionSubInfo.java:[9,52] package com.hcb.neurotec.migrations.conversion.pojos does not exist
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/pojo/RConversionSubInfo.java:[10,52] package com.hcb.neurotec.migrations.conversion.pojos does not exist
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/pojo/RConversionSubInfo.java:[11,52] package com.hcb.neurotec.migrations.conversion.pojos does not exist
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/pojo/RConversionSubInfo.java:[12,52] package com.hcb.neurotec.migrations.conversion.pojos does not exist
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/pojo/RConversionSubInfo.java:[13,52] package com.hcb.neurotec.migrations.conversion.utils does not exist
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/pojo/RConversionSubInfo.java:[27,59] package com.hcb.neurotec.migrations.conversion.utils does not exist
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/pojo/RConversionSubInfo.java:[31,13] cannot find symbol
[ERROR] symbol: class DirectoryUtils
[ERROR] location: class com.hcb.runtime.migrations.conversion.pojo.RConversionSubInfo
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/pojo/RConversionSubInfo.java:[32,13] cannot find symbol
[ERROR] symbol: class ConversionDemograhpicsInfo
[ERROR] location: class com.hcb.runtime.migrations.conversion.pojo.RConversionSubInfo
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/pojo/RConversionSubInfo.java:[33,13] cannot find symbol
[ERROR] symbol: class ConversionFaceInfo
[ERROR] location: class com.hcb.runtime.migrations.conversion.pojo.RConversionSubInfo
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/pojo/RConversionSubInfo.java:[34,13] cannot find symbol
[ERROR] symbol: class ConversionPrintInfo
[ERROR] location: class com.hcb.runtime.migrations.conversion.pojo.RConversionSubInfo
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/pojo/RConversionSubInfo.java:[35,13] cannot find symbol
[ERROR] symbol: class ConversionIrisInfo
[ERROR] location: class com.hcb.runtime.migrations.conversion.pojo.RConversionSubInfo
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/pojo/RConversionSubInfo.java:[39,13] cannot find symbol
[ERROR] symbol: class SubjectDemographicsConverter
[ERROR] location: class com.hcb.runtime.migrations.conversion.pojo.RConversionSubInfo
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/pojo/RConversionSubInfo.java:[44,74] cannot find symbol
[ERROR] symbol: class SubjectDemographicsConverter
[ERROR] location: class com.hcb.runtime.migrations.conversion.pojo.RConversionSubInfo
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/pojo/RConversionSubInfo.java:[50,42] cannot find symbol
[ERROR] symbol: class ConversionException
[ERROR] location: class com.hcb.runtime.migrations.conversion.pojo.RConversionSubInfo
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/pojo/RConversionSubInfo.java:[63,42] cannot find symbol
[ERROR] symbol: class ConversionException
[ERROR] location: class com.hcb.runtime.migrations.conversion.pojo.RConversionSubInfo
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/pojo/RConversionSubInfo.java:[95,35] cannot find symbol
[ERROR] symbol: class SubjectDemographicsConverter
[ERROR] location: class com.hcb.runtime.migrations.conversion.pojo.RConversionSubInfo
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/pojo/RConversionSubInfo.java:[95,101] cannot find symbol
[ERROR] symbol: class ConversionException
[ERROR] location: class com.hcb.runtime.migrations.conversion.pojo.RConversionSubInfo
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/pojo/RConversionSubInfo.java:[171,43] cannot find symbol
[ERROR] symbol: class ConversionException
[ERROR] location: class com.hcb.runtime.migrations.conversion.pojo.RConversionSubInfo
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/pojo/RConversionSubInfo.java:[205,43] cannot find symbol
[ERROR] symbol: class ConversionException
[ERROR] location: class com.hcb.runtime.migrations.conversion.pojo.RConversionSubInfo
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/pojo/RConversionSubInfo.java:[238,12] cannot find symbol
[ERROR] symbol: class ConversionDemograhpicsInfo
[ERROR] location: class com.hcb.runtime.migrations.conversion.pojo.RConversionSubInfo
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/RConvertedRecordInfo.java:[7,56] package com.hcb.neurotec.migrations.conversion.exception does not exist
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/RConvertedRecordInfo.java:[8,52] package com.hcb.neurotec.migrations.conversion.utils does not exist
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/RConvertedRecordInfo.java:[25,13] cannot find symbol
[ERROR] symbol: class DirectoryUtils
[ERROR] location: class com.hcb.runtime.migrations.conversion.RConvertedRecordInfo
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/RConvertedRecordInfo.java:[63,69] cannot find symbol
[ERROR] symbol: class ConversionException
[ERROR] location: class com.hcb.runtime.migrations.conversion.RConvertedRecordInfo
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/RuntimeConversionApplication.java:[3,56] package com.hcb.neurotec.migrations.conversion.exception does not exist
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/RuntimeConversionApplication.java:[4,54] package com.hcb.neurotec.migrations.conversion.network does not exist
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/RuntimeConversionApplication.java:[5,54] package com.hcb.neurotec.migrations.conversion.network does not exist
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/RuntimeConversionApplication.java:[6,61] package com.hcb.neurotec.migrations.conversion.network.config does not exist
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/RuntimeConversionApplication.java:[18,51] cannot find symbol
[ERROR] symbol: class ConversionException
[ERROR] location: class com.hcb.runtime.migrations.conversion.RuntimeConversionApplication
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/RuntimeConversionImpl.java:[3,46] package com.hcb.neurotec.migrations.conversion does not exist
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/RuntimeConversionImpl.java:[4,56] package com.hcb.neurotec.migrations.conversion.exception does not exist
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/RuntimeConversionImpl.java:[5,54] package com.hcb.neurotec.migrations.conversion.network does not exist
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/RuntimeConversionImpl.java:[6,54] package com.hcb.neurotec.migrations.conversion.network does not exist
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/RuntimeConversionImpl.java:[7,52] package com.hcb.neurotec.migrations.conversion.utils does not exist
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/RuntimeConversionImpl.java:[15,59] package com.hcb.neurotec.migrations.conversion.utils does not exist
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/RuntimeConversionImpl.java:[15,1] static import only from classes and interfaces
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/RuntimeConversionImpl.java:[19,19] cannot find symbol
[ERROR] symbol: class SubjectDemographicsConverter
[ERROR] location: class com.hcb.runtime.migrations.conversion.RuntimeConversionImpl
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/RuntimeConversionImpl.java:[22,34] cannot find symbol
[ERROR] symbol: class EnrolmentAPI
[ERROR] location: class com.hcb.runtime.migrations.conversion.RuntimeConversionImpl
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/RuntimeConversionImpl.java:[22,61] cannot find symbol
[ERROR] symbol: class ConfigurationAPI
[ERROR] location: class com.hcb.runtime.migrations.conversion.RuntimeConversionImpl
[ERROR] /C:/Users/ikechukwua/IdeaProjects/migration-bioenrol/runtime-migrations-conversion/src/main/java/com/hcb/runtime/migrations/conversion/RuntimeConversionImpl.java:[26,80] cannot find symbol
[ERROR] symbol: class ConversionException
[ERROR] location: class com.hcb.runtime.migrations.conversion.RuntimeConversionImpl
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
I have checked that they're both accounted for in the parent pom, I also ensured that the older module built successfully with 'mvn clean install' before trying to build the module where it is used as a dependency.
Solved the error. Found out that the module I intend on importing as a dependency when built with mvn clean install, does not build correctly in the first place because:
<build>
<plugins>
<!-- Add class with main method to manifest-->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.3.4.RELEASE</version>
<configuration>
<mainClass>com.hcb.neurotec.migrations.conversion.AbisExportConverter</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
The module is not a spring project, so when the build gets to this block of code, it encounters issues that aren't surprisingly flagged. Removing this block in the old module allowed the new module build successfully.

cannot find symbol symbol: class DockerImageName

I have been trying to run an sbomtest that invokes a cyclonedx-cli docker image using test containers but the
import org.testcontainers.images.DockerImageName; doesn't work properly
Here is what I want the test to do for me
The SBOMTest class defines a GenericContainer field named cyclonedxCli that is annotated with the #Rule annotation. This container is based on the cyclonedx/cyclonedx-cli Docker image, and it maps a classpath resource at /path/to/sboms to the path /app/sboms in the container.
The testSBOMValidation method is a JUnit test that starts the cyclonedxCli container, runs the cyclonedx-cli validate command in the container to validate an SBOM file, and then stops the container.
The test method uses the execInContainer method of the GenericContainer class to run the cyclonedx-cli command in the container, and it stores the command's output and exit code in the result variable.
The test method then uses the assertThat method from the AssertJ library to assert that the command's exit code is zero. This indicates that the command completed successfully.
Finally, the test method stops the cyclonedxCli container using the stop method of the GenericContainer class.
Below is my SBOMTest class and my pom.xml. Why doesn't my test pass?
package com.mkyong.hashing;
import org.junit.Rule;
import org.junit.Test;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.images.DockerImageName;
import org.testcontainers.images.DockerImageName;
import static org.assertj.core.api.Assertions.assertThat;
public class SBOMTest {
public static final DockerImageName CYCLONEDX_CLI_IMAGE = DockerImageName.parse("cyclonedx/cyclonedx-cli:v0.24.2");
#Rule
public GenericContainer<?> cyclonedxCli = new GenericContainer<>(CYCLONEDX_CLI_IMAGE)
.withClasspathResourceMapping("/home/ntn/workdir", "/app/sboms", BindMode.READ_ONLY);
#Test
public void testSBOMValidation() throws Exception {
// Start the container
cyclonedxCli.start();
// Validate the SBOM file using the cyclonedx-cli command
String sbomFileName = "/home/ntn/workdir/julian.json";
Container.ExecResult result = cyclonedxCli.execInContainer("cyclonedx-cli", "validate", "--input-file", sbomFileName, "--fail-on-errors");
String stdout = result.getStdout();
// Assert that the command returned a zero exit code
assertThat(result.getExitCode()).isZero();
// Stop the container
cyclonedxCli.stop();
}
}
Below is my pom.xml
<?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>com.mkyong.hashing</groupId>
<artifactId>java-project</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>java-project</name>
<url>http://maven.apache.org</url>
<properties>
<!-- https://maven.apache.org/general.html#encoding-warning -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>1.14.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.11</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.0</version>
<executions>
<!-- Attach the shade into the package phase -->
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.mkyong.hashing.App</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<!-- fat-jar -->
<!-- https://books.sonatype.com/mvnex-book/reference/customizing-sect-custom-packaged.html -->
<!--
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.mkyong.hashing.App</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>simple-command</id>
<phase>package</phase>
<goals>
<goal>attached</goal>
</goals>
</execution>
</executions>
</plugin>
-->
</plugins>
</build>
</project>
I was expecting the test to pass successfully
The following are the error logs
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/usr/share/maven/lib/guice.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< com.mkyong.hashing:java-project >-------------------
[INFO] Building java-project 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # java-project ---
[INFO] Deleting /home/ntn/outreachytest/maven-examples/java-project/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # java-project ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/ntn/outreachytest/maven-examples/java-project/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # java-project ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /home/ntn/outreachytest/maven-examples/java-project/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # java-project ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/ntn/outreachytest/maven-examples/java-project/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # java-project ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to /home/ntn/outreachytest/maven-examples/java-project/target/test-classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/ntn/outreachytest/maven-examples/java-project/src/test/java/com/mkyong/hashing/SBOMTest.java:[6,33] cannot find symbol
symbol: class DockerImageName
location: package org.testcontainers.images
[ERROR] /home/ntn/outreachytest/maven-examples/java-project/src/test/java/com/mkyong/hashing/SBOMTest.java:[7,33] cannot find symbol
symbol: class DockerImageName
location: package org.testcontainers.images
[ERROR] /home/ntn/outreachytest/maven-examples/java-project/src/test/java/com/mkyong/hashing/SBOMTest.java:[10,35] package org.assertj.core.api does not exist
[ERROR] /home/ntn/outreachytest/maven-examples/java-project/src/test/java/com/mkyong/hashing/SBOMTest.java:[10,1] static import only from classes and interfaces
[ERROR] /home/ntn/outreachytest/maven-examples/java-project/src/test/java/com/mkyong/hashing/SBOMTest.java:[14,25] cannot find symbol
symbol: class DockerImageName
location: class com.mkyong.hashing.SBOMTest
[ERROR] /home/ntn/outreachytest/maven-examples/java-project/src/test/java/com/mkyong/hashing/SBOMTest.java:[14,63] cannot find symbol
symbol: variable DockerImageName
location: class com.mkyong.hashing.SBOMTest
[ERROR] /home/ntn/outreachytest/maven-examples/java-project/src/test/java/com/mkyong/hashing/SBOMTest.java:[18,78] cannot find symbol
symbol: variable BindMode
location: class com.mkyong.hashing.SBOMTest
[ERROR] /home/ntn/outreachytest/maven-examples/java-project/src/test/java/com/mkyong/hashing/SBOMTest.java:[27,18] package Container does not exist
[INFO] 8 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.466 s
[INFO] Finished at: 2022-12-26T06:24:21+03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile (default-testCompile) on project java-project: Compilation failure: Compilation failure:
[ERROR] /home/ntn/outreachytest/maven-examples/java-project/src/test/java/com/mkyong/hashing/SBOMTest.java:[6,33] cannot find symbol
[ERROR] symbol: class DockerImageName
[ERROR] location: package org.testcontainers.images
[ERROR] /home/ntn/outreachytest/maven-examples/java-project/src/test/java/com/mkyong/hashing/SBOMTest.java:[7,33] cannot find symbol
[ERROR] symbol: class DockerImageName
[ERROR] location: package org.testcontainers.images
[ERROR] /home/ntn/outreachytest/maven-examples/java-project/src/test/java/com/mkyong/hashing/SBOMTest.java:[10,35] package org.assertj.core.api does not exist
[ERROR] /home/ntn/outreachytest/maven-examples/java-project/src/test/java/com/mkyong/hashing/SBOMTest.java:[10,1] static import only from classes and interfaces
[ERROR] /home/ntn/outreachytest/maven-examples/java-project/src/test/java/com/mkyong/hashing/SBOMTest.java:[14,25] cannot find symbol
[ERROR] symbol: class DockerImageName
[ERROR] location: class com.mkyong.hashing.SBOMTest
[ERROR] /home/ntn/outreachytest/maven-examples/java-project/src/test/java/com/mkyong/hashing/SBOMTest.java:[14,63] cannot find symbol
[ERROR] symbol: variable DockerImageName
[ERROR] location: class com.mkyong.hashing.SBOMTest
[ERROR] /home/ntn/outreachytest/maven-examples/java-project/src/test/java/com/mkyong/hashing/SBOMTest.java:[18,78] cannot find symbol
[ERROR] symbol: variable BindMode
[ERROR] location: class com.mkyong.hashing.SBOMTest
[ERROR] /home/ntn/outreachytest/maven-examples/java-project/src/test/java/com/mkyong/hashing/SBOMTest.java:[27,18] package Container does not exist
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

When I try to upgrade my Spring Framework version, the whole projects have problems

I am currently using Spring Framework version 4.1.6.RELEASE. When I try to upgrade its version to 4.2.4.RELEASE, my projects is in trouble.
Upgrading version to 4.1.7 - 4.2.3 is totally fine, but I need above 4.2.4 version. Can anyone tell me what is wrong here?
Here is my entire pom.xml.
And now I am also having this problem while I am testing my api with jUnit.
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.isu</groupId>
<artifactId>ifm</artifactId>
<name>IfMobileHrAdapterService</name>
<packaging>war</packaging>
<version>1.0.0-BUILD-SNAPSHOT</version>
<properties>
<!-- Generic properties -->
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<!-- Spring -->
<springframework.version>4.2.5.RELEASE</springframework.version>
<springframework.jpa.version>1.8.0.RELEASE</springframework.jpa.version>
<springframework.ldap.version>2.0.3.RELEASE</springframework.ldap.version>
<!-- Mysql -->
<db.version>5.1.35</db.version>
<!-- Hibernate / JPA -->
<hibernate.version>4.3.8.Final</hibernate.version>
<hibernate.validator.version>5.1.3.Final</hibernate.validator.version>
<hibernate.core.version>4.3.8.Final</hibernate.core.version>
<org.aspectj-version>1.8.5</org.aspectj-version>
<!-- Logging -->
<org.slf4j-version>1.6.6</org.slf4j-version>
<!-- Test -->
<junit.version>4.11</junit.version>
</properties>
<repositories>
<repository>
<id>thirdparty</id>
<url>http://hatch.pearbranch.com:8081/content/repositories/thirdparty</url>
</repository>
</repositories>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.apache.tika/tika-core -->
<dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika-core</artifactId>
<version>1.8</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.tika/tika -->
<dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika</artifactId>
<version>1.8</version>
<type>pom</type>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.3.2</version>
</dependency>
<!-- Oracle -->
<dependency>
<groupId>oracle</groupId>
<artifactId>OracleDriver</artifactId>
<version>11.2.0.1.0</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/webapp/WEB-INF/lib/ojdbc6.jar</systemPath>
</dependency>
<dependency>
<groupId>log4sql</groupId>
<artifactId>log4sql</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/webapp/WEB-INF/lib/log4sql.jar</systemPath>
</dependency>
<!-- JSON -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20141113</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
</dependency>
<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${springframework.version}</version>
<exclusions>
<!-- Exclude Commons Logging in favor of SLF4j -->
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- https://mvnrepository.com/artifact/log4j/apache-log4j-extras -->
<dependency>
<groupId>log4j</groupId>
<artifactId>apache-log4j-extras</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${springframework.version}</version>
</dependency>
</dependencies>
<build>
<!-- <sourceDirectory>src</sourceDirectory> -->
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
</project>
PS D:\Workspace\SpringToolSuiteProjects\ifMobileApiUnitTest> mvn clean package
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.isu:ifm:war:1.0.0-BUILD-SNAPSHOT
[WARNING] 'dependencies.dependency.systemPath' for oracle:OracleDriver:jar should not point at files within the project directory, ${basedir}/src/main/webapp/WEB-INF/lib/ojdbc6.jar will be unresolvable by dependent projects # line 76, column 16
[WARNING] 'dependencies.dependency.systemPath' for log4sql:log4sql:jar should not point at files within the project directory, ${basedir}/src/main/webapp/WEB-INF/lib/log4sql.jar will be unresolvable by dependent projects # line 84, column 16
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: org.springframework:spring-beans:jar -> duplicate declaration of version ${springframework.version} # line 178, column 15
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ----------------------------< com.isu:ifm >-----------------------------
[INFO] Building IfMobileHrAdapterService 1.0.0-BUILD-SNAPSHOT
[INFO] --------------------------------[ war ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # ifm ---
[INFO] Deleting D:\Workspace\SpringToolSuiteProjects\ifMobileApiUnitTest\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # ifm ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) # ifm ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 4 source files to D:\Workspace\SpringToolSuiteProjects\ifMobileApiUnitTest\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/LoginControllerTest.java:[4,17] package org.junit does not exist
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/LoginControllerTest.java:[5,17] package org.junit does not exist
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/LoginControllerTest.java:[6,24] package org.junit.runner does not exist
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/LoginControllerTest.java:[7,19] package org.mockito does not exist
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/LoginControllerTest.java:[8,19] package org.mockito does not exist
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/LoginControllerTest.java:[9,19] package org.mockito does not exist
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/LoginControllerTest.java:[18,30] package com.isu.ifm.hr.control does not exist
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/LoginControllerTest.java:[19,30] package com.isu.ifm.hr.service does not exist
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/LoginControllerTest.java:[21,2] cannot find symbol
symbol: class RunWith
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/LoginControllerTest.java:[26,23] cannot find symbol
symbol: class LoginService
location: class com.isu.ifm.testcase.LoginControllerTest
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/LoginControllerTest.java:[27,30] cannot find symbol
symbol: class LoginController
location: class com.isu.ifm.testcase.LoginControllerTest
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/SalaryControllerTest.java:[4,17] package org.junit does not exist
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/SalaryControllerTest.java:[5,17] package org.junit does not exist
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/SalaryControllerTest.java:[6,24] package org.junit.runner does not exist
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/SalaryControllerTest.java:[14,30] package com.isu.ifm.hr.control does not exist
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/SalaryControllerTest.java:[16,2] cannot find symbol
symbol: class RunWith
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/SalaryControllerTest.java:[23,9] cannot find symbol
symbol: class SalaryController
location: class com.isu.ifm.testcase.SalaryControllerTest
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/EDocumentControllerTest.java:[4,17] package org.junit does not exist
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/EDocumentControllerTest.java:[6,24] package org.junit.runner does not exist
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/EDocumentControllerTest.java:[14,30] package com.isu.ifm.hr.control does not exist
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/EDocumentControllerTest.java:[16,2] cannot find symbol
symbol: class RunWith
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/EDocumentControllerTest.java:[23,9] cannot find symbol
symbol: class EDocumentController
location: class com.isu.ifm.testcase.EDocumentControllerTest
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/LoginControllerTest.java:[26,10] cannot find symbol
symbol: class Mock
location: class com.isu.ifm.testcase.LoginControllerTest
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/LoginControllerTest.java:[27,10] cannot find symbol
symbol: class InjectMocks
location: class com.isu.ifm.testcase.LoginControllerTest
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/LoginControllerTest.java:[34,6] cannot find symbol
symbol: class Before
location: class com.isu.ifm.testcase.LoginControllerTest
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/LoginControllerTest.java:[40,6] cannot find symbol
symbol: class Test
location: class com.isu.ifm.testcase.LoginControllerTest
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/SalaryControllerTest.java:[25,6] cannot find symbol
symbol: class Before
location: class com.isu.ifm.testcase.SalaryControllerTest
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/SalaryControllerTest.java:[30,6] cannot find symbol
symbol: class Test
location: class com.isu.ifm.testcase.SalaryControllerTest
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/EDocumentControllerTest.java:[25,6] cannot find symbol
symbol: class Before
location: class com.isu.ifm.testcase.EDocumentControllerTest
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/EDocumentControllerTest.java:[30,6] cannot find symbol
symbol: class Test
location: class com.isu.ifm.testcase.EDocumentControllerTest
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/LoginControllerTest.java:[36,9] cannot find symbol
symbol: variable MockitoAnnotations
location: class com.isu.ifm.testcase.LoginControllerTest
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/SalaryControllerTest.java:[23,49] cannot find symbol
symbol: class SalaryController
location: class com.isu.ifm.testcase.SalaryControllerTest
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/EDocumentControllerTest.java:[23,55] cannot find symbol
symbol: class EDocumentController
location: class com.isu.ifm.testcase.EDocumentControllerTest
[INFO] 33 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.814 s
[INFO] Finished at: 2018-11-02T18:07:26+09:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile (default-compile) on project ifm: Compilation failure: Compilation failure:
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/LoginControllerTest.java:[4,17] package org.junit does not exist
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/LoginControllerTest.java:[5,17] package org.junit does not exist
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/LoginControllerTest.java:[6,24] package org.junit.runner does not exist
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/LoginControllerTest.java:[7,19] package org.mockito does not exist
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/LoginControllerTest.java:[8,19] package org.mockito does not exist
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/LoginControllerTest.java:[9,19] package org.mockito does not exist
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/LoginControllerTest.java:[18,30] package com.isu.ifm.hr.control does not exist
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/LoginControllerTest.java:[19,30] package com.isu.ifm.hr.service does not exist
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/LoginControllerTest.java:[21,2] cannot find symbol
[ERROR] symbol: class RunWith
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/LoginControllerTest.java:[26,23] cannot find symbol
[ERROR] symbol: class LoginService
[ERROR] location: class com.isu.ifm.testcase.LoginControllerTest
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/LoginControllerTest.java:[27,30] cannot find symbol
[ERROR] symbol: class LoginController
[ERROR] location: class com.isu.ifm.testcase.LoginControllerTest
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/SalaryControllerTest.java:[4,17] package org.junit does not exist
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/SalaryControllerTest.java:[5,17] package org.junit does not exist
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/SalaryControllerTest.java:[6,24] package org.junit.runner does not exist
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/SalaryControllerTest.java:[14,30] package com.isu.ifm.hr.control does not exist
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/SalaryControllerTest.java:[16,2] cannot find symbol
[ERROR] symbol: class RunWith
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/SalaryControllerTest.java:[23,9] cannot find symbol
[ERROR] symbol: class SalaryController
[ERROR] location: class com.isu.ifm.testcase.SalaryControllerTest
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/EDocumentControllerTest.java:[4,17] package org.junit does not exist
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/EDocumentControllerTest.java:[6,24] package org.junit.runner does not exist
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/EDocumentControllerTest.java:[14,30] package com.isu.ifm.hr.control does not exist
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/EDocumentControllerTest.java:[16,2] cannot find symbol
[ERROR] symbol: class RunWith
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/EDocumentControllerTest.java:[23,9] cannot find symbol
[ERROR] symbol: class EDocumentController
[ERROR] location: class com.isu.ifm.testcase.EDocumentControllerTest
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/LoginControllerTest.java:[26,10] cannot find symbol
[ERROR] symbol: class Mock
[ERROR] location: class com.isu.ifm.testcase.LoginControllerTest
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/LoginControllerTest.java:[27,10] cannot find symbol
[ERROR] symbol: class InjectMocks
[ERROR] location: class com.isu.ifm.testcase.LoginControllerTest
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/LoginControllerTest.java:[34,6] cannot find symbol
[ERROR] symbol: class Before
[ERROR] location: class com.isu.ifm.testcase.LoginControllerTest
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/LoginControllerTest.java:[40,6] cannot find symbol
[ERROR] symbol: class Test
[ERROR] location: class com.isu.ifm.testcase.LoginControllerTest
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/SalaryControllerTest.java:[25,6] cannot find symbol
[ERROR] symbol: class Before
[ERROR] location: class com.isu.ifm.testcase.SalaryControllerTest
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/SalaryControllerTest.java:[30,6] cannot find symbol
[ERROR] symbol: class Test
[ERROR] location: class com.isu.ifm.testcase.SalaryControllerTest
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/EDocumentControllerTest.java:[25,6] cannot find symbol
[ERROR] symbol: class Before
[ERROR] location: class com.isu.ifm.testcase.EDocumentControllerTest
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/EDocumentControllerTest.java:[30,6] cannot find symbol
[ERROR] symbol: class Test
[ERROR] location: class com.isu.ifm.testcase.EDocumentControllerTest
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/LoginControllerTest.java:[36,9] cannot find symbol
[ERROR] symbol: variable MockitoAnnotations
[ERROR] location: class com.isu.ifm.testcase.LoginControllerTest
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/SalaryControllerTest.java:[23,49] cannot find symbol
[ERROR] symbol: class SalaryController
[ERROR] location: class com.isu.ifm.testcase.SalaryControllerTest
[ERROR] /D:/Workspace/SpringToolSuiteProjects/ifMobileApiUnitTest/src/main/java/com/isu/ifm/testcase/EDocumentControllerTest.java:[23,55] cannot find symbol
[ERROR] symbol: class EDocumentController
[ERROR] location: class com.isu.ifm.testcase.EDocumentControllerTest
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
i have also faced the same problem while updating the spring version
i checked your POM.XML File so there is no jackson dependency so add below dependency it works
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.8.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.8.1</version>
</dependency>
if you not used above dependency version use the latest version of dependency which version you want.
Just changing the version should work but you have to follow the instructions by spring community.
But before that clear the m2 repository and do clean install to download maven dependencies again in case if corrupted jars.
Upgrading-to-Spring-Framework-4.x
And try to do eclipse clean project and then Maven > update project should solve your issue.follow steps given below.
Project -> Clean
Restart Eclipse
Disable then re-enable dependency management (right-click Maven -> Disable Dependency Management then Maven -> Enable Dependency Management
Close and Reopen Project
Project -> Run as -> Maven Build -> Set goals as clean install -> Select options Update Snapshots Debug Output Non Recursive Resolve Workspace Artifacts -> Apply and Run
Repeat Step 5 after removing dependencies from ~/.m2/repository
Check that your Maven settings are configured correctly. If you are behind a proxy you'll need to configure the proxy settings in the global or user settings.

Maven fails on compile java project

From eclipse I am trying to perform a maven install but I gets some errors:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building analyzer 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # distributed.analyzer ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 9 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # distributed.analyzer ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 14 source files to D:\eclipse-workspace\DistributedAnalyzer\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Analizador.java:[8,32] package org.apache.logging.log4j does not exist
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Analizador.java:[9,32] package org.apache.logging.log4j does not exist
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Analizador.java:[22,30] cannot find symbol
symbol: class Logger
location: class com.distributed.analyzer.Analizador
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Ordenante.java:[7,32] package org.apache.logging.log4j does not exist
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Ordenante.java:[8,32] package org.apache.logging.log4j does not exist
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Ordenante.java:[31,30] cannot find symbol
symbol: class Logger
location: class com.distributed.analyzer.Ordenante
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Manager.java:[8,32] package org.apache.logging.log4j does not exist
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Manager.java:[9,32] package org.apache.logging.log4j does not exist
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Manager.java:[22,30] cannot find symbol
symbol: class Logger
location: class com.distributed.analyzer.Manager
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Main.java:[6,32] package org.apache.logging.log4j does not exist
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Main.java:[7,32] package org.apache.logging.log4j does not exist
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Main.java:[22,30] cannot find symbol
symbol: class Logger
location: class com.distributed.analyzer.Main
[INFO] 12 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 19.481 s
[INFO] Finished at: 2016-02-12T20:04:47+01:00
[INFO] Final Memory: 16M/184M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project distributed.analyzer: Compilation failure: Compilation failure:
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Analizador.java:[8,32] package org.apache.logging.log4j does not exist
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Analizador.java:[9,32] package org.apache.logging.log4j does not exist
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Analizador.java:[22,30] cannot find symbol
[ERROR] symbol: class Logger
[ERROR] location: class com.distributed.analyzer.Analizador
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Ordenante.java:[7,32] package org.apache.logging.log4j does not exist
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Ordenante.java:[8,32] package org.apache.logging.log4j does not exist
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Ordenante.java:[31,30] cannot find symbol
[ERROR] symbol: class Logger
[ERROR] location: class com.distributed.analyzer.Ordenante
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Manager.java:[8,32] package org.apache.logging.log4j does not exist
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Manager.java:[9,32] package org.apache.logging.log4j does not exist
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Manager.java:[22,30] cannot find symbol
[ERROR] symbol: class Logger
[ERROR] location: class com.distributed.analyzer.Manager
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Main.java:[6,32] package org.apache.logging.log4j does not exist
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Main.java:[7,32] package org.apache.logging.log4j does not exist
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Main.java:[22,30] cannot find symbol
[ERROR] symbol: class Logger
[ERROR] location: class com.distributed.analyzer.Main
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
log4j2 jars are added as maven dependencies in my pom.xml:
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.5</version>
</dependency>
Also they are present in java build path in eclipse in the libraries tab.
I have added these two libraries in run/debug setting in eclipse, in the classpath tab.
Maven dependency tree:
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-core</artifactId>
<version>4.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-jms</artifactId>
<version>4.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.1.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
<version>1.1.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>4.1.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.5</version>
</dependency>
</dependencies>
What am I doing wrong?

Maven doesn't find org.junit even though it's in the dependencies

I wanted to add a test to my small project (please note I removed some bits from the code & changed package names, so if there's any error you see regarding this it might be not this ;)):
package my.pckg;
import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class SignedRequestCallbackTest {
#Before
public void setUp() throws Exception {
}
#After
public void tearDown() throws Exception {
}
#Test
public void testCorrectSignedRequest() {
assertTrue(false);
}
}
(I also tried to extend from TestCase in order to remove the static import but it didn't help)
After running mvn test it shows me an error that it couldn't find org.junit:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Test Server 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) # server ---
[WARNING] Using platform encoding (MacRoman actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) # server ---
[WARNING] File encoding has not been set, using platform encoding MacRoman, i.e. build is platform dependent!
[INFO] Compiling 9 source files to /Users/michael/Projects/fbmuc/server/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] ~/code/src/test/java/my/pckg/SignedRequestCallbackTest.java:[4,27] package org.junit does not exist
[ERROR] ~/code/src/test/java/my/pckg/SignedRequestCallbackTest.java:[6,16] package org.junit does not exist
[ERROR] ~/code/src/test/java/my/pckg/SignedRequestCallbackTest.java:[7,16] package org.junit does not exist
[ERROR] ~/code/src/test/java/my/pckg/SignedRequestCallbackTest.java:[8,16] package org.junit does not exist
[ERROR] ~/code/src/test/java/my/pckg/SignedRequestCallbackTest.java:[14,9] cannot find symbol
symbol : class Before
location: class my.pckgSignedRequestCallbackTest
[ERROR] ~/code/src/test/java/my/pckg/SignedRequestCallbackTest.java:[18,9] cannot find symbol
symbol : class After
location: class my.pckgSignedRequestCallbackTest
[ERROR] ~/code/src/test/java/my/pckg/SignedRequestCallbackTest.java:[22,9] cannot find symbol
symbol : class Test
location: class my.pckgSignedRequestCallbackTest
[ERROR] ~/code/src/test/java/my/pckg/SignedRequestCallbackTest.java:[24,12] cannot find symbol
symbol : method assertTrue(boolean)
location: class my.pckgSignedRequestCallbackTest
[INFO] 9 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.161s
[INFO] Finished at: Fri Feb 22 18:02:37 CET 2013
[INFO] Final Memory: 8M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project server: Compilation failure: Compilation failure:
[ERROR] ~/code/src/test/java/my/pckg/SignedRequestCallbackTest.java:[4,27] package org.junit does not exist
[ERROR] ~/code/src/test/java/my/pckg/SignedRequestCallbackTest.java:[4,4] static import only from classes and interfaces
[ERROR] ~/code/src/test/java/my/pckg/SignedRequestCallbackTest.java:[6,16] package org.junit does not exist
[ERROR] ~/code/src/test/java/my/pckg/SignedRequestCallbackTest.java:[7,16] package org.junit does not exist
[ERROR] ~/code/src/test/java/my/pckg/SignedRequestCallbackTest.java:[8,16] package org.junit does not exist
[ERROR] ~/code/src/test/java/my/pckg/SignedRequestCallbackTest.java:[14,9] cannot find symbol
[ERROR] symbol : class Before
[ERROR] location: class my.pckgSignedRequestCallbackTest
[ERROR] ~/code/src/test/java/my/pckg/SignedRequestCallbackTest.java:[18,9] cannot find symbol
[ERROR] symbol : class After
[ERROR] location: class my.pckgSignedRequestCallbackTest
[ERROR] ~/code/src/test/java/my/pckg/SignedRequestCallbackTest.java:[22,9] cannot find symbol
[ERROR] symbol : class Test
[ERROR] location: class my.pckgSignedRequestCallbackTest
[ERROR] ~/code/src/test/java/my/pckg/SignedRequestCallbackTest.java:[24,12] cannot find symbol
[ERROR] symbol : method assertTrue(boolean)
[ERROR] location: class my.pckgSignedRequestCallbackTest
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
My pom.xml looks like this:
<?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>com.example</groupId>
<artifactId>server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>TestServer</name>
<description>Test</description>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- Facebook library -->
<dependency>
<groupId>com.restfb</groupId>
<artifactId>restfb</artifactId>
<version>1.6.11</version>
</dependency>
<!-- Gson: Java to Json conversion -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.2</version>
<scope>compile</scope>
</dependency>
<!-- Tigase server snapshot -->
<dependency>
<groupId>tigase</groupId>
<artifactId>tigase-server</artifactId>
<version>5.2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.7</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>tigase</id>
<name>Tigase repository</name>
<url>http://maven.tigase.org</url>
</repository>
<repository>
<id>tigase-snapshot</id>
<name>Tigase repository</name>
<url>http://build.xmpp-test.net/maven/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</project>
mvn dependency:tree:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Test Server 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) # server ---
[INFO] my.pckg:server:jar:0.0.1-SNAPSHOT
[INFO] +- com.restfb:restfb:jar:1.6.11:compile
[INFO] +- com.google.code.gson:gson:jar:2.2.2:compile
[INFO] +- tigase:tigase-server:jar:5.2.0-SNAPSHOT:compile
[INFO] | +- tigase:tigase-utils:jar:3.4.1-SNAPSHOT:compile
[INFO] | \- tigase:tigase-xmltools:jar:3.4.3-SNAPSHOT:compile
[INFO] +- commons-codec:commons-codec:jar:1.7:compile
[INFO] \- junit:junit:jar:4.11:test
[INFO] \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.240s
[INFO] Finished at: Fri Feb 22 18:07:55 CET 2013
[INFO] Final Memory: 5M/81M
[INFO] ------------------------------------------------------------------------
mvn version:
Apache Maven 3.0.3 (r1075438; 2011-02-28 18:31:09+0100)
Maven home: /usr/share/maven
Java version: 1.6.0_41, vendor: Apple Inc.
Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Default locale: de_CH, platform encoding: MacRoman
OS name: "mac os x", version: "10.8.2", arch: "x86_64", family: "mac"
Please note that I'm not an expert in java nor in maven, just getting started (especially with maven).
From what I've seen from other articles and questions, I should have my tests within src/test/java and my "real" code within src/main/java - I have done it like this.
Also I removed once the whole ~/.m2/ folder and it still didn't work.
I also did run mvn test -X but it didn't help me. If I should post it please tell me so.
You shouldn't override your <sourceDirectory> setting in the POM's <build> element unless you have a good reason to. This attribute determines where Maven looks for non-test code. The default value for this attribute is src/main/java. The <testSourceDirectory> attribute sets the path to test code (this defaults to src/test/java. By setting the <sourceDirectory> to simply src, Maven considers that entire directory to contain main application code. Since the src directory contains src/test/java, Maven then tries to compile your test code as part of the main application.
This is significant because when compiling the main application (during the compile phase), Maven omits dependencies with test scope. Test code is compiled in a separate phase (the test-compile phase) after the main compile.
So since Maven tried to compile your test code as part of the main application, it omitted the junit dependency, and they weren't available on the classpath. The solution here is to simply not specify the <sourceDirectory> element in the POM.
By default , maven looks at these folders for java and test classes respectively - src/main/java and src/test/java
When the src is specified with the test classes under source and the scope for junit dependency in pom.xml is mentioned as test - org.unit will not be found by maven.
Just putting image to #matts Answer, so its easy for other to correct the problems.
<sourceDirectory>src</sourceDirectory>
just delete or comment this line present in pom.xml
<!-- <sourceDirectory>src</sourceDirectory> !-->
For explanation please go through #matt's answer

Categories