简体   繁体   English

Spring启动运行多个应用程序

[英]Spring boot run multiple applications

I have one project with multiple modules, every module itself is spring boot application. 我有一个包含多个模块的项目,每个模块本身都是spring boot应用程序。 I need to run all this applications with one command(using .bat for windows OR one maven run), how can I do it? 我需要使用一个命令运行所有这些应用程序(使用.bat for windows或一个maven运行),我该怎么办?

Project structure looking like this: 项目结构如下:

/base-app
  /auth-service
     /pom.xml - child pom
  /eureka-service
     /pom.xml
  /zuul-service
     /pom.xml
pom.xml - main pom

I can't understand at all how to do it with maven. 我根本无法理解如何用maven做到这一点。 But I tried to do it with .bat file like this: 但我尝试用.bat文件这样做:

call mvn -f eureka-service/pom.xml spring-boot:run
call mvn -f zuul/pom.xml spring-boot:run

First "call" worked fine, but second one was ignored. 第一个“通话”工作正常,但第二个被忽略了。
I need this to fast start all my services. 我需要这个来快速启动我的所有服务。

This smells monolith all over. 这种气味遍布各地。 I can't really justify use of a parent pom, in a microservice world (arguable). 在微服务世界中,我无法证明使用父pom是合理的(可论证)。 This is just my honest opinion, your scenario might be totally different. 这只是我的诚实意见,您的情况可能完全不同。

That being said, I believe, each of the child projects (auth-service,euraka and zuul) are creating it's own artifacts (jars). 话虽如此,我相信,每个子项目(auth-service,euraka和zuul)都在创建它自己的工件(罐子)。 If yes, you can just do java -jar on each of that in your .bat or shell commands. 如果是,您可以在.bat或shell命令中的每一个上执行java -jar

If you run each of your services in a separate Docker container, Docker Compose will do what you're looking for and bring up all the services in their containers in one command with: 如果您在一个单独的Docker容器中运行每个服务,Docker Compose将执行您正在寻找的内容,并在一个命令中显示其容器中的所有服务:

docker-compose up

See https://docs.docker.com/compose/ 请参阅https://docs.docker.com/compose/

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

相关问题 多个Spring Boot应用程序 - Multiple Spring Boot Applications 有没有办法在 IntelliJ IDEA 中使用单个运行配置运行多个 Spring Boot 应用程序? - Is there a way to run multiple Spring Boot applications with a single Running Configuration in IntelliJ IDEA? nginx - spring boot 应用程序的多个反向代理(启用 spring 安全) - nginx - multiple reverse proxy for spring boot applications (enabled spring security) 如何在同一台服务器上运行两个 Spring Boot 应用程序? - How to run two spring boot applications on same server? 在单个服务器中部署多个Spring Boot Web应用程序 - Deploying Multiple Spring Boot Web Applications in Single Server 如何在一次测试中测试多个 Spring Boot 应用程序? - How to test multiple Spring Boot applications in one test? 如何在同一个 Tomcat 上部署多个带有外部配置的 Spring Boot 应用程序? - How to deploy multiple Spring boot applications with external configurations on the same Tomcat? 如何使用多个 CommandLineRunner 运行 Spring Boot App - How to run Spring Boot App with multiple CommandLineRunner 在多个服务器地址上运行 Spring 引导应用程序 - Run Spring Boot application on multiple server address 在一个jvm中运行多个spring boot jar - Run multiple spring boot jars in one jvm
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM