繁体   English   中英

Springboot 构建

[英]Springboot build

我有一个基于 Springboot 框架构建的系统,它运行两个服务,如图所示:

在此处输入图像描述

我需要构建 stock-quote-manager 以将其容器化。 我尝试使用 mvnw 以这种方式构建它:

./mvnw spring-boot:build-image

但它引发了一个错误,让我相信我需要重构整个代码,将 stockquotemanager 或 stockmanager 移动到另一个 package。 有没有其他方法可以在不进行任何重构的情况下构建它?

这是 mvnw 错误:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  33.107 s
[INFO] Finished at: 2021-02-28T10:33:14-03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.4.3:repackage (repackage) on project stock-quote-manager: Execution repackage of goal org.springframework.boot:spring-boot-maven-plugin:2.4.3:repackage failed: Unable to find a single main class from the following candidates [com.br.inatel.stockmanager.StockManagerApplication, com.br.inatel.stockquotemanager.StockQuoteManagerApplication] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

我不知道这是否相关,但 StockManager 在端口 8080 上运行,stockQuoteManager 在端口 8081 上运行。

提前致谢,

您收到此错误是因为您对一个项目 StockQuoteManagerApplication 和 StockManagerApplication 有多个主要方法。 您必须将这两者分开并在单独的 tomcat 实例中运行它们(即创建两个不同的项目),然后您才能为每个服务获得两个单独的端口。 因为它们都在同一个 tomcat 实例中运行,所以只提供一个端口。

在 Project 文件夹中添加Docker文件,并按照官方 Spring 文档中的说明执行以下操作。

Spring 用 Docker 启动谢谢。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM