xybrek xybrek - 3 years ago 115
Java Question

Maven compile "Cannot find symbol"

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
mvn clean install -DskipTests=true -Psdk

In the POM the repository have this:



[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] -------------------------------------------------------------
[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

Answer Source

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


from the pom.xml

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download