Maven编译“找不到符号" [英] Maven compile "Cannot find symbol"

查看:112
本文介绍了Maven编译“找不到符号"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出于某种原因,这个命令在我的本地机器上运行良好:

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

mvn clean install -DskipTests=true -Psdk

但是对于 Codeship,它现在可以工作并抛出此找不到符号"错误.在 Codeship 中,完整的命令是:

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

在 POM 中,存储库有:

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>

错误:

[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

推荐答案

您的 Maven 正在读取 Java 版本为 1.8,而 pom.xml 表示版本为 1.7.

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

尝试安装所需的版本.

如果已经安装,请检查您的 $JAVA_HOME 环境变量,它应该包含 Java JDK 8 的路径.如果找不到,请修复您的环境变量.

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.

也删除线

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

来自 pom.xml

这篇关于Maven编译“找不到符号"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆