Jenkins构建项目时的Maven依赖问题 [英] maven dependency problem when jenkins builds the project

查看:1456
本文介绍了Jenkins构建项目时的Maven依赖问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个Maven项目,比方说A和B,仅A需要B,反之则不成立.当我从Eclipse打包A时没有问题.在项目A的"pom.xml"中,B具有依赖项节点.在jenkins中,我通过添加三个目标(即干净软件包安装")配置了项目B.因此,只要B的构建完成,它就必须存在于本地Maven存储库中B的存档文件中(我检查了它).另一方面,当我构建项目A时,出现很多编译错误找不到符号x".可能是什么问题,有什么想法吗?

I have two maven projects, let's say A and B, merely A requires B, reverse is not true. There is no problem when I package A from eclipse. In the "pom.xml" of the project A has a dependency node on B. In jenkins, I configured the project B by adding three goals, which are "clean package install". Therefore, whenever the build of B finishes, it must be exist the archive file of the B in my local maven repository that there is(I checked it). On the other hand, when I build the project A, I got lots of compilation errors "cannot find symbol x". What might be the problem, any ideas?

谢谢.

推荐答案

只需确保:您调查了~jenkins/.m2/repository/,是吗?

Just to make sure: You looked into ~jenkins/.m2/repository/, yes?

请注意,install始终包含package,因此clean install就足够了.

Note that install always includes package, so clean install is enough.

但是问题出在其他地方.

But the problem is elsewhere.

  1. 检查版本是否相同.在A的依赖项中使用确切的版本号,而不是版本范围,以确保它能正确选择(否则,Maven可能会找到更合适的"版本).

  1. Check that the versions are the same. Use an exact version number in the dependency of A, not a version range to make sure what it picks up (otherwise, Maven might find a "more suitable" version).

如果不存在依赖项,则Maven不会启动编译器(因为构建类路径会失败).因此,问题不是JAR文件,而是内容.确保B的JAR文件确实包含您期望的内容(jar tvf是您的朋友).

If the dependency wasn't there, Maven wouldn't start the compiler (because building the classpath would fail). So the problem is not the JAR file but the content. Make sure that B's JAR file really contains what you expect (jar tvf is your friend).

删除Jenkins服务器上的存储库,以确保其中没有旧的垃圾.

Delete the repository on the Jenkins server to make sure there is no old junk in there.

这篇关于Jenkins构建项目时的Maven依赖问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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