有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何修复Jenkins中的“错误:找不到符号”?

我使用Jenkins + Netbeans (Java code) + GitContinuous Integration环境中工作。我正在尝试将Jacoco插件与Ant任务一起使用,以便进行代码覆盖。我有一个不同于默认版本(build.xml)的版本。我创建了另一个,但当我运行“编译测试”ant任务时,我得到的是:

compile-tests:<br>
[javac] Compiling 1 source file to C:\CITestApp\bin\classes-tests</br>
[javac] C:\CITestApp\test\citestapp\logic\CalculatorTest.java:22: error: cannot find symbol</br>
[javac]     private Calculate calculator;
[javac]             ^
[javac]   symbol:   class Calculate
[javac]   location: class CalculatorTest
[javac] C:\CITestApp\test\citestapp\logic\CalculatorTest.java:37: error: cannot find symbol
[javac]         calculator = new Calculate();
[javac]                          ^
[javac]   symbol:   class Calculate
[javac]   location: class CalculatorTest
[javac] 2 errors

BUILD FAILED
C:\CITestApp\jacocorep.xml:29: Compile failed; see the compiler error output for details.

我怎样才能知道这个错误是什么意思:

"error: cannot find symbol"


共 (1) 个答案

  1. # 1 楼答案

    以下是我在ant构建中创建的目标,我在其中定义了将要编译的测试的类路径:

    <target name="compile"> <mkdir dir="${classes.dir}"/> <javac fork="true" debug="true" srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath" includeantruntime="false" /> </target>>;

    <target name="compile-tests" depends="compile"> <mkdir dir="${classes.dir}-tests"/> <javac fork="true" debug="true" srcdir="${test.dir}" destdir="${classes.dir}-tests" classpathref="classpath" includeantruntime="false"> <classpath> <pathelement location="${lib.dir}/junit-4.10.jar"/> <path refid="application"/> </classpath> </javac> </target>

    我有另一个构建(这是默认的project build.xml),我在其中编译并执行项目中的单元测试。我在项目根目录中有这两个ant构建,所以我不知道类路径是否正确

    我一开始就这样定义了类路径:

    <path id="classpath"> <fileset dir="${lib.dir}" includes="org/osgi/**/*.jar"/> </path> <path id="application" location="{classes.dir}"/>