繁体   English   中英

通过Jenkins运行Maven项目(Git存储库)时出现编译错误

[英]Compilation Error while Running Maven Project(Git Repository) through Jenkins

我在詹金斯(Jenkins)建立了一个Maven项目。 我对代码进行了更新,提交并推送到远程(Git存储库)。 我将maven目标配置为测试的jenkins,然后单击生成,然后在Jenkins中编译类时出现错误。 据我所知,Maven仅使用src / test / java路径下存在的那些类进行测试。 当我通过Jenkins构建项目时,出现了以下编译错误,

[INFO] --- maven-compiler-plugin:3.0:compile (default-compile) @ myTestMaven ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\Users\s\.jenkins\workspace\meven_jenkin_sele\myTestMaven\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/s/.jenkins/workspace/meven_jenkin_sele/myTestMaven/src/main/java/com/testingMeven/myTestMaven/App.java:[3,30] package org.testng.annotations does not exist
[ERROR] /C:/Users/s/.jenkins/workspace/meven_jenkin_sele/myTestMaven/src/main/java/com/testingMeven/myTestMaven/App.java:[16,6] cannot find symbol
  symbol:   class Test
  location: class com.testingMeven.myTestMaven.App
[INFO] 2 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE

我的git repo链接https://github.com/SACTAN/myTestMaven

我尝试为App.java添加注释,但仍然遇到相同的错误。 当我在本地计算机上运行相同的代码时,它可以正常工作,但不能通过詹金斯工作。 任何想法可能出什么问题吗?

您不能在src/main对范围test使用依赖项。 如果要在主代码中使用TestNG,则可以从POM中的TestNG dependency中删除<scope>test</scope>

这适用于任何Maven依赖关系,而不仅仅是TestNG。 阅读Dependency Scope了解更多信息。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM