英文:
Maven downloads all dependencies again because they were "cached from a remote repository ID that is unavailable in current build context"
问题
在第一步,我下载并缓存所有依赖项(我使用Maven目标package
来执行此操作)。这个Docker层是未来所有构建步骤的基础。
在第二步,我构建项目。
然而,在第二步中,所有依赖项都会再次被下载。我通过使用dive确保在Maven存储库中已经存在这些依赖项,并且使用了正确的Maven存储库。
当我以调试模式运行Maven,通过传递-X
参数,我在每次重新下载依赖项之前都会收到以下警告:
"Artifact XYZ is present in the local repository, but cached from a remote repository ID that is unavailable in current build context, verifying that is downloadable from XYZ"
我该如何解决这个警告?如何防止Maven重新下载依赖项?
英文:
I have a multi-staged Docker build.
In step one, I download and cache all dependencies (I use the Maven goal package
for this). This is Docker layer is the base for all future build steps.
In step two, I build the project.
However, in step two, all dependencies get downloaded again. I made sure by using dive that the dependencies already exist in the Maven repository before and that the correct Maven repository is used.
When I run Maven in debugging mode by passing -X
, I get this warning before each dependency is downloaded again:
> Artifact XYZ is present in the local repository, but cached from a
> remote repository ID that is unavailable in current build context,
> verifying that is downloadable from XYZ
Here is the Maven source code where it is printed.
How can I solve this warning? How to keep Maven from downloading the dependencies again?
答案1
得分: 0
问题在于我以为dependency:resolve
也会下载所有依赖项。但事实并非如此。
英文:
The problem was that I thought dependency:resolve
also downloads all dependencies. But that's not what it does.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论