我一直在网上闲逛,找了几天的解决方案。我已经尝试了所有可能的解决方案,但还没有运气。问题看起来很简单,但我无法解决它。 尽管代码在Eclipse中编译和运行完全正常,但它在运行CI作业(Jenkins)时会出错。请参阅下面的错误。
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0:testCompile (default-testCompile) on project clctnnotificationservFunctionalTests: Compilation failure: Compilation failure:
01:16:35 [ERROR] /clctnnotificationserv-ci-2959/workspace/clctnnotificationserv-ci-2959/clctnnotificationservFunctionalTests/src/test/java/com/paypal/collections/decision/tests/NotificationTest.java:[117,9] error: cannot find symbol
有问题的陈述是:
user = PayPalAccountCreator.createUser(data);
我'我试图调用静态方法createUser(),它位于源文件夹" src / test / java"但是一个不同的包(注意:此方法存在于不同的源文件夹" src / main / java"之前,由于此问题后来将其移动到相同的源文件夹,但它没有解决它)
这是我的pom.xml
<dependencies>
<!-- Add exclusion to all in the below dependency to avoid SSLPeerAuthentication issue
when running rbo tests using RBOTestFramework -->
<dependency>
<groupId>com.paypal.test.qi.jaws</groupId>
<artifactId>Jaws</artifactId>
<version>${jawsUserVersion}</version>
</dependency>
<dependency>
<groupId>xmlunit</groupId>
<artifactId>xmlunit</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>com.paypal.test.qi.jaws</groupId>
<artifactId>jaws-restclients</artifactId>
<version>${jawsUserVersion}</version>
</dependency>
<dependency>
<groupId>com.paypal.test.qi.jaws</groupId>
<artifactId>jaws-raptorinfra-provider</artifactId>
<version>${jawsUserVersion}</version>
</dependency>
<dependency>
<groupId>com.paypal.test.services</groupId>
<artifactId>restclienttestng</artifactId>
<version>1.1.3-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.paypal.test</groupId>
<artifactId>RiskTestUtilities</artifactId>
<version>0.0.20</version>
<exclusions>
<exclusion>
<artifactId>Bluefin-GUI</artifactId>
<groupId>com.paypal.test.bluefin</groupId>
</exclusion>
<exclusion>
<artifactId>Jaws</artifactId>
<groupId>com.paypal.test</groupId>
</exclusion>
<exclusion>
<artifactId>jaws-asfclient-deps</artifactId>
<groupId>com.paypal.test</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>${suiteXmlFile}</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<inherited>false</inherited>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
com.ebay.raptor.build
</groupId>
<artifactId>
build-info-maven-plugin
</artifactId>
<versionRange>
[1.2.0-RELEASE,)
</versionRange>
<goals>
<goal>addscminfo</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore>true</ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
构建步骤:
答案 0 :(得分:0)
最后找到了解决方案。 这是由于在src / main / java文件夹中定义了一个变量,但该变量已在src / test / java中使用。 一旦将变量移至src / test / java,一切都很好。我猜可能是由于Java在src / main / java之前先编译src / test / java。由于变量存在于其他源文件夹中,因此找不到该变量,因此出现错误“找不到符号”。如果我的理解有误,请更正。