gpt4 book ai didi

maven - Dockerfile中的Maven生命周期

转载 作者:行者123 更新时间:2023-12-02 19:38:47 25 4
gpt4 key购买 nike

首先感谢您的宝贵时间。我试图在dockerfile中运行Maven命令:

# Base container contains maven, jdk on ubuntu
FROM maven:3-jdk-8
# copy my build config pom file to container
ADD pom.xml /app/
# copy the source file directory to the container
ADD src/ /app/src/
# move the app directory inside container to perform mvn buill
WORKDIR /app/
RUN ["mvn", "dependency:resolve"]
RUN ["mvn", "verify"]
# resolve dependency offline as suggested by Nicolas
#RUN mvn dependency:go-offline
# build by using maven
RUN mvn package

但是我在代理方面有问题:
$ docker build -t mavenimagen .
Sending build context to Docker daemon 124.9 kB
Step 1 : FROM maven:3-jdk-8
---> b2ef69e414f5
Step 2 : ADD pom.xml /app/
---> Using cache
---> 57e5b52fe34b
Step 3 : ADD src/ /app/src/
---> Using cache
---> ace1a117cb4f
Step 4 : WORKDIR /app/
---> Using cache
---> da544b2298a1
Step 5 : RUN mvn dependency:resolve
---> Running in 26258aec0093
[INFO] Scanning for projects...
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-jar-plugin/2.4/maven-jar-plugin-2.4.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-jar-plugin:2.4: Plugin org.apache.maven.plugins:maven-jar-plugin:2.4 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-jar-plugin:jar:2.4
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-shade-plugin/2.1/maven-shade-plugin-2.1.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-shade-plugin:2.1: Plugin org.apache.maven.plugins:maven-shade-plugin:2.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-shade-plugin:jar:2.1
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-clean-plugin:2.5: Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.5
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.6/maven-resources-plugin-2.6.pom

我想我必须添加settings.xml,但是我不知道是否必须在项目的根目录或其他目录中添加。

问候!

最佳答案

您尚未发布确切的代理问题,但是无论它是什么,您都可能必须放置自定义的settings.xml文件(ADD settings.xml /app/),然后将其与Maven(RUN mvn -s settings.xml package)一起使用。

如果将要进行多个调用,建议将settings.xml放入~/.m2/,以便默认情况下将在每个Maven调用中使用它。

关于maven - Dockerfile中的Maven生命周期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41142478/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com