只需按一下按钮就可以在 IntelliJ 中运行多个应用程序吗?

是否有一种方法可以只需按一下按钮就可以运行多个应用程序?

假设,我有 阿帕应用程式应用程式资讯中心(它们都是 Java 语言)。有没有一种方法,他们可以运行所有3在某种顺序,只需要一个按钮按下?

对于大约10个应用程序来说,点击“运行”按钮有点乏味。我假设是一个脚本或者插件?

58844 次浏览

There is no such feature yet, please vote:

  • IDEA-94341 Launch Multiple "Run/Debug Configurations" At Once

There seems to be a Multirun plugin for IDEA:

Allows to run multiple run configurations at once: group multiple run configurations and start them in a single click. Not only application and test run configurations can be grouped, but other Multirun configurations can be organized into single run configuration.

I think this has been possible since version 15. You simply create a Run/Debug Configuration of type 'Compound', and select the configurations you want to run, so:

  1. Ensure you have previously set up run configurations for the various applications (or other run configurations) that you want to run.
  2. Click on the 'Run' menu
  3. Click 'Edit Configurations'
  4. Click the green '+' icon (top-left of the window)
  5. Click 'Compound'
  6. In the right-hand pane, enter a meaningful name for your group, then click the green '+' icon (the one in the right-hand pane, not the top-left of the window)
  7. Select one of the run configurations
  8. Repeat 5 and 6 for all the configurations you want to run in a single click
  9. Hit OK
  10. Select your newly-created compound configuration in the drop-down in the menu bar
  11. Hit the run button (note that you don't appear to be able start all the applications in debug mode, if you want to do that, you'll need to do so individually)
  12. Watch all your applications start, one-by-one. Revel in your newly discovered free time

2 drawbacks:

  1. As CashIsClay points out below, you can't explicitly change the order that your configurations run in; they run in alphabetical order. I'm not sure that this is a big restriction though, I'd want my applications to be able to start in any order for resilience in production environments. Of course, a non-terrible workaround would be to name your run configurations something like: '1. Foo'; '2. Bar', if it's essential for Foo to run before Bar starts.
  2. You can only start in 'run' mode, not 'debug'.

Other answers have mentioned the Multirun plugin, which may offer more functionality than IntelliJ's native options. I haven't used it, but it might be worth looking at.

You can do this. Go to Run -> Edit Configurations....

Older IntelliJ versions:
Check Allow parallel run, then you can start multiple main classes.

IntelliJ 2020+:
Select Modify options. A popup appears. Enable Allow multiple instances.

Edit run configuration, check the allow run parallel checkbox.

You can agroup the projects, go to "Edit Configurations..."

enter image description here

The following screen will open, under "Application" configure your settings

enter image description here

Once you create a "Compound"

enter image description here

And put "Compound" your settings

enter image description here

Done, just run the "Compound"

enter image description here

Select the Written program(java/Scala) --> right click --> Edit --> Select Allow parallel runs check boxenter image description here