java 有没有办法在 IntelliJ IDEA 中使用单个运行配置运行多个 Spring Boot 应用程序?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36055601/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is there a way to run multiple Spring Boot applications with a single Running Configuration in IntelliJ IDEA?
提问by ikryvorotenko
I have multiple spring boot applications in a single IntelliJ project. And i want to have a single button to run all of them in some order.
我在一个 IntelliJ 项目中有多个 Spring Boot 应用程序。我想要一个按钮来按某种顺序运行所有这些。
I know there is an option to Run Another configuration
before launching the original one, so in that way the configurations can be chained.
我知道Run Another configuration
在启动原始版本之前有一个选项,因此可以通过这种方式链接配置。
But when i use it, it runs that Another Configuration and doesn't run the original one.
但是当我使用它时,它运行另一个配置而不运行原始配置。
So I'm wondering if anyone met this issue and how it was resolved?
所以我想知道是否有人遇到过这个问题以及它是如何解决的?
回答by Stephane Nicoll
You could create a Compound
run type and add all your applications in it. That way you can just run that config and all your apps will start.
您可以创建一个Compound
运行类型并将所有应用程序添加到其中。这样你就可以运行那个配置,你的所有应用程序都会启动。
回答by dustin.schultz
Update April 2016:
2016 年 4 月更新:
Multirun Plugin says: Prefer to use built-in support starting from IntelliJIdea 15 https://www.jetbrains.com/idea/help/run-debug-configuration-compound.html
Multirun 插件说:更 喜欢使用从 IntelliJIdea 15 开始的内置支持https://www.jetbrains.com/idea/help/run-debug-configuration-compound.html
Stéphane's answer works great but if you need additional features you can install the MultiRun Plugin
that will allow you to do the same as the Compound
run type but with more bells and whistles.
Stéphane 的答案效果很好,但是如果您需要其他功能,您可以安装它MultiRun Plugin
,这将允许您执行与Compound
运行类型相同的操作,但具有更多功能。
https://plugins.jetbrains.com/plugin/7248
https://plugins.jetbrains.com/plugin/7248
For instance: You can set a delay between each configuration run or run one configuration after another using the Before Launch feature.
例如:您可以设置每次配置运行之间的延迟,或者使用“启动前”功能一个接一个地运行配置。
See here for more info about how to setup: https://github.com/rkhmelyuk/multirun/wiki/How-to-run-configurations-with-Multirun
有关如何设置的更多信息,请参见此处:https: //github.com/rkhmelyuk/multirun/wiki/How-to-run-configurations-with-Multirun
回答by Fas
Update April 2018:
2018 年 4 月更新:
On the "Run configurations" combo box, click "Edit Configurations". Then uncheck "Single instance only" option. Then click "Apply".
在“运行配置”组合框中,单击“编辑配置”。然后取消选中“仅单个实例”选项。然后点击“应用”。
Then you can click the button "Run" any times you want, launching a new instance each time.
然后您可以随时单击“运行”按钮,每次都启动一个新实例。
IntelliJIDEA Ultimate 2018.1
IntelliJIDEA Ultimate 2018.1
回答by Rameez Shikalgar
Yes you can achieve this by launching a standalone java app which will spawn multiple threads per microservice and start them. You can find a sample code [here]: https://github.com/rameez4ever/springboot-demo.git
是的,您可以通过启动一个独立的 Java 应用程序来实现这一点,该应用程序将为每个微服务生成多个线程并启动它们。您可以在 [此处] 找到示例代码:https: //github.com/rameez4ever/springboot-demo.git
回答by yuranos
Another note to reduce ambiguity: What was called Run Dashboardin a lot of sources in the past is now called Services.
减少歧义的另一个注意事项:过去在许多来源中称为Run Dashboard现在称为Services。
回答by usertest
it's called allow parallel runas of 2018.3instead of Single instance only
它被称为自2018.3 起允许并行运行,而不是仅单个实例
回答by rahulnikhare
Yes.
是的。
Goto "Run configurations" combo box, click "Edit Configurations". Then unchecked "Single instance only" option. Then click "Apply"
转到“运行配置”组合框,单击“编辑配置”。然后取消选中“仅单个实例”选项。然后点击“应用”
For Eureka Server:
对于尤里卡服务器:
1.Run the application without serve.port.
1.运行没有serve.port的应用程序。
2.Add server.port =9999 in application.properties. Run the application.
2.在application.properties中添加server.port =9999。运行应用程序。
Now browse Eureka dashboard, you will have 2 instances running.
现在浏览 Eureka 仪表板,您将有 2 个实例正在运行。