英文:
How to build docker image for multi-module spring boot application using Jib
问题
我有一个 Spring Boot 应用程序,其中有许多模块,例如 error 模块、持久化模块、控制器模块等,如下所示:
--Application
|
-- error 模块
|
-- 控制器模块
|
-- 持久化模块
|
-- .....
使用以下在 pom.xml 中的配置使用 Maven jib 插件来构建此应用程序的 Docker 镜像
构建成功。但是当我运行该镜像时,抛出错误 Error: Could not find or load the main class com.a.b.c.Application.
我应该如何使用 Jib 构建镜像?我在这里漏掉了什么?
英文:
I have a Spring boot application which has many modules like error module, persistency, controllers etc like below
--Application
|
-- error module
|
-- controllers module
|
-- Persistancy module
|
-- .....
To build docker image for this using Maven jib plugin with below configuration in pom.xml
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>2.4.0</version>
<configuration>
<to>
<image>some.repo.io/my_name/jib-test</image>
</to>
<container>
<mainClass>com.a.b.c.Application</mainClass>
<ports>
<port>8080</port>
</ports>
</container>
</configuration>
</plugin>
Build is successful. But when I run the image, its throwing error Error: Could not find or load the main class com.a.b.c.Application.
How can I build the image using Jib ?. What am I missing here?
答案1
得分: 0
在您的 pom.xml 文件中添加:
<modules>
<module>error</module>
<module>controllers </module>
<module>Persistancy </module>
</modules>
然后从您的终端运行以下命令:
mvn -Pprod verify com.google.cloud.tools:jib-maven-plugin:dockerBuild
英文:
In your pom.xml, add:
<modules>
<module>error</module>
<module>controllers </module>
<module>Persistancy </module>
</modules>
Then run the following from your terminal:
mvn -Pprod verify com.google.cloud.tools:jib-maven-plugin:dockerBuild
专注分享java语言的经验与见解,让所有开发者获益!
评论