Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven compile "Cannot find symbol" [duplicate]

For some reason this command works fine with my local machine:

mvn clean install -DskipTests=true -Psdk

However for Codeship it does now work and throws this "Cannot find symbol" error. In Codeship the full command is:

jdk_switcher use oraclejdk8
echo $JAVA_HOME
mvn clean install -DskipTests=true -Psdk

In the POM the repository have this:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.1</version>
    <configuration>
        <source>1.7</source>
        <target>1.7</target>
    </configuration>
</plugin>

Error:

[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ client-app ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 65 source files to /home/rof/src/bitbucket.org/company/client-app/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /home/rof/src/bitbucket.org/company/client-app/src/main/java/com/client/rest/resources/MyResource.java:[3,61] cannot find symbol
symbol:   class MyEntity
like image 491
quarks Avatar asked Feb 11 '23 06:02

quarks


2 Answers

Your Maven is reading Java version as 1.8, Where as the pom.xml says the version is 1.7.

Try installing the required verison.

If already installed check your $JAVA_HOME environment variable, it should contain the path of Java JDK 8. If you dont find it, fix your environment variable.

also remove the lines

 <fork>true</fork>
     <executable>${JAVA_1_8_HOME}/bin/javac</executable>

from the pom.xml

like image 63
Shubham Jain Avatar answered Feb 12 '23 20:02

Shubham Jain


I had the same issue. reason was one of the class was used in

src/main/java/

Where as in actual it was present in

src/test/java
like image 38
user4906240 Avatar answered Feb 12 '23 19:02

user4906240