【发布时间】:2022-01-20 18:07:25
【问题描述】:
我正在尝试使用spring-boot-maven-plugin:2.5.6:build-image 来构建应用程序映像。我的pom.xml 中有一个用于构建映像的个人资料,
<profile>
<id>build-image</id>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>build-image</goal>
</goals>
</execution>
</executions>
<configuration>
<docker>
<publishRegistry>
<username>${docker.publish.username}</username>
<password>${docker.publish.password}</password>
<url>https://registry.example.com</url>
</publishRegistry>
</docker>
<publish>true</publish>
<image>
<env>
<HTTP_PROXY>https://proxy.example.com:8080</HTTP_PROXY>
<HTTPS_PROXY>https://proxy.example.com:8443</HTTPS_PROXY>
<NO_PROXY>localhost,127.0.0.1,example.com</NO_PROXY>
</env>
</image>
</configuration>
</plugin>
</plugins>
</build>
</profile>
我正在使用这样的命令来构建图像,
mvn clean deploy \
-P build-image \
-Dspring-boot.build-image.imageName=example/image:latest
我的问题是如何在命令行上传递其他spring-boot.build-image 属性?我可以设置图像名称,但无法弄清楚其他属性。特别是代理配置。我尝试过类似的变体,
mvn clean deploy \
-P build-image \
-Dspring-boot.build-image.imageName=example/image:latest \
-Dspring-boot.build-image.image.env.HTTP_PROXY="https://proxy.example.com:8080" \
-Dspring-boot.build-image.image.env.HTTPS_PROXY="https://proxy.example.com:8443" \
-Dspring-boot.build-image.image.env.NO_PROXY="localhost,127.0.0.1,example.com"
我似乎不知道如何通过-D 设置这些代理变量。有人知道要在命令行上设置的属性吗?
我已经找到了定义这些属性的class,它在javadoc 中列出了env,但我没有看到设置env 属性的实际方法。这是那个类的sn-p,
/**
* Image configuration, with {@code builder}, {@code runImage}, {@code name},
* {@code env}, {@code cleanCache}, {@code verboseLogging}, {@code pullPolicy}, and
* {@code publish} options.
* @since 2.3.0
*/
@Parameter
private Image image;
/**
* Alias for {@link Image#name} to support configuration via command-line property.
* @since 2.3.0
*/
@Parameter(property = "spring-boot.build-image.imageName", readonly = true)
String imageName;
谢谢
【问题讨论】:
标签: java spring spring-boot maven proxy