Maven fails on compile java project - java

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?

Related

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: package io.swagger.annotations does not exist

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).

Running scala under maven project

i am running scala project .I woudld like to use maven project but , it seems doesn't recognize scala .Because before i used add scala nature now i would ike to add scala through maven , but i can't get it doesnt .i used scala 2.11.8
here is the 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>SynchData</groupId>
<artifactId>SynchData</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-catalyst_2.11</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.11</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_2.11</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_2.11</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.1.3</version>
</dependency>
<!-- <dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId>
<version>9.2-1002-jdbc4</version> </dependency> -->
<!-- https://mvnrepository.com/artifact/oracle/ojdbc6 -->
<dependency>
<groupId>oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Once i make maven clean install i got this
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for SynchData:SynchData:jar:0.0.1-SNAPSHOT
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: org.apache.spark:spark-sql_2.11:jar -> duplicate declaration of version 2.2.0 # line 31, 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] ------------------------------------------------------------------------
[INFO] Building SynchData 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # SynchData ---
[INFO] Deleting C:\Users\MHT\eclipse-workspace\test.iptech\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # SynchData ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.6.1:compile (default-compile) # SynchData ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 1 source file to C:\Users\MHT\eclipse-workspace\test.iptech\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/MHT/eclipse-workspace/test.iptech/src/main/java/LauncherPack/SynchronizeData.java:[2,1] package SynchronizePackage does not exist
[ERROR] /C:/Users/MHT/eclipse-workspace/test.iptech/src/main/java/LauncherPack/SynchronizeData.java:[10,17] cannot find symbol
symbol: variable MainFunction
location: class LauncherPack.SynchronizeData
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.277 s
[INFO] Finished at: 2017-09-26T14:29:59+01:00
[INFO] Final Memory: 36M/281M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:compile (default-compile) on project SynchData: Compilation failure: Compilation failure:
[ERROR] /C:/Users/MHT/eclipse-workspace/test.iptech/src/main/java/LauncherPack/SynchronizeData.java:[2,1] package SynchronizePackage does not exist
[ERROR] /C:/Users/MHT/eclipse-workspace/test.iptech/src/main/java/LauncherPack/SynchronizeData.java:[10,17] cannot find symbol
[ERROR] symbol: variable MainFunction
[ERROR] location: class LauncherPack.SynchronizeData
[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
Please any help to get it work without using add scala nature through eclipse .
Thanks a lot

Error while building spring boot project [duplicate]

This question already has answers here:
How to add a dependency to a Spring Boot Jar in another project?
(12 answers)
Closed 5 years ago.
i am unable to build my springboot project,
I am using classes from another springboot jar, which i placed on the build path, its running in local via eclipse, but is not building, here's the error
"[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building ContentManagementService 0.0.1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # contentmanagementapi ---
[INFO] Deleting /home/bhargavgundu/git/contentmanagementservice/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # contentmanagementapi ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 5 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # contentmanagementapi ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 42 source files to /home/bhargavgundu/git/contentmanagementservice/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/bhargavgundu/git/contentmanagementservice/src/main/java/com/conduiraonline/controller/ContentManagementControllerV1.java:[32,31] package com.conduiraonline.apis does not exist
[ERROR] /home/bhargavgundu/git/contentmanagementservice/src/main/java/com/conduiraonline/controller/ContentManagementControllerV1.java:[42,31] package com.conduiraonline.daos does not exist
[ERROR] /home/bhargavgundu/git/contentmanagementservice/src/main/java/com/conduiraonline/controller/ContentManagementControllerV1.java:[52,35] cannot find symbol
symbol: class SlackService
location: package com.conduiraonline.services
[ERROR] /home/bhargavgundu/git/contentmanagementservice/src/main/java/com/conduiraonline/controller/ContentManagementControllerV1.java:[85,17] cannot find symbol
symbol: class UserDAO
location: class com.conduiraonline.controller.ContentManagementControllerV1
[ERROR] /home/bhargavgundu/git/contentmanagementservice/src/main/java/com/conduiraonline/controller/ContentManagementControllerV1.java:[87,17] cannot find symbol
symbol: class SlackService
location: class com.conduiraonline.controller.ContentManagementControllerV1
[ERROR] /home/bhargavgundu/git/contentmanagementservice/src/main/java/com/conduiraonline/controller/ContentManagementControllerV1.java:[95,17] cannot find symbol
symbol: class LicenseV5
location: class com.conduiraonline.controller.ContentManagementControllerV1
[INFO] 6 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.917s
[INFO] Finished at: Tue Sep 12 17:16:44 IST 2017
[INFO] Final Memory: 24M/396M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project contentmanagementapi: Compilation failure: Compilation failure:
[ERROR] /home/bhargavgundu/git/contentmanagementservice/src/main/java/com/conduiraonline/controller/ContentManagementControllerV1.java:[32,31] package com.conduiraonline.apis does not exist
[ERROR] /home/bhargavgundu/git/contentmanagementservice/src/main/java/com/conduiraonline/controller/ContentManagementControllerV1.java:[42,31] package com.conduiraonline.daos does not exist
[ERROR] /home/bhargavgundu/git/contentmanagementservice/src/main/java/com/conduiraonline/controller/ContentManagementControllerV1.java:[52,35] cannot find symbol
[ERROR] symbol: class SlackService
[ERROR] location: package com.conduiraonline.services
[ERROR] /home/bhargavgundu/git/contentmanagementservice/src/main/java/com/conduiraonline/controller/ContentManagementControllerV1.java:[85,17] cannot find symbol
[ERROR] symbol: class UserDAO
[ERROR] location: class com.conduiraonline.controller.ContentManagementControllerV1
[ERROR] /home/bhargavgundu/git/contentmanagementservice/src/main/java/com/conduiraonline/controller/ContentManagementControllerV1.java:[87,17] cannot find symbol
[ERROR] symbol: class SlackService
[ERROR] location: class com.conduiraonline.controller.ContentManagementControllerV1
[ERROR] /home/bhargavgundu/git/contentmanagementservice/src/main/java/com/conduiraonline/controller/ContentManagementControllerV1.java:[95,17] cannot find symbol
[ERROR] symbol: class LicenseV5
[ERROR] location: class com.conduiraonline.controller.ContentManagementControllerV1
[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
"
It is showing errors wherever i am using classes/functions from the external jar, can someone help?
MY POM-
here is my POM
<?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.conduiraonline</groupId>
<artifactId>contentmanagementapi</artifactId>
<version>0.0.1</version>
<packaging>jar</packaging>
<name>ContentManagementService</name>
<description>ContentManagementService</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.3.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.mail/mail -->
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>com.conduiraonline</groupId>
<artifactId>licenseapi</artifactId>
<version>0.0.1</version>
<classifier>exec</classifier>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>21.0</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
</configuration>
</plugin>
</plugins>
</build>
</project>
TL;DR
Remove <classifier>exec</classifier> from the dependency on com.conduiraonline:licenseapi
More Details ...
You are correct in using <dependency> to express the relationship between com.conduiraonline:contentmanagementapi and com.conduiraonline:licenseapi. Or to put it another way; this is the right way to tell Maven that the module com.conduiraonline:contentmanagementapi depends on the module com.conduiraonline:licenseapi.
However, you have defined the dependency on com.conduiraonline:licenseapi as:
<dependency>
<groupId>com.conduiraonline</groupId>
<artifactId>licenseapi</artifactId>
<version>0.0.1</version>
<classifier>exec</classifier>
</dependency>
The classifier tells Maven to look for an file named licenseapi.exec in the folder com/conduiraonline in your local Maven repo (and failing that, try to resolve that dependency from whatever remote repositories you have configured in your Maven settings.xml or in this pom.xml).
I presume there is no file named licenseapi.exec in the folder com/conduiraonline in your local Maven repo because exec is a very unusual classifier for a Maven artifact.
As long as a JAR for com.conduiraonline:licenseapi with version 0.0.1 has been installed in your local Maven repo this dependency will work:
<dependency>
<groupId>com.conduiraonline</groupId>
<artifactId>licenseapi</artifactId>
<version>0.0.1</version>
</dependency>
You install a JAR for com.conduiraonline:licenseapi with version 0.0.1 in your local Maven repo by running mvn clean install for the licenseapi module (assuming that the pom.xml for the licenseapi modules has <version>0.0.1</version>).
You must add the path of your jars / folder containing jars in your gradle or maven build file.
For example in gradle add
compile fileTree(dir: 'path_to_ext_libs', include: '*.jar')
to your dependencies in the build.gradle then all the jars in the libs folder will be then included.
or in maven
<repositories>
<repository>
<id>local-files</id>
<name>local-files</name>
<url>file://c:\test\filerepo</url>
</repository>

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