31

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.

I know there is an option to Run Another configuration before launching the original one, so in that way the configurations can be chained.

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?

ikryvorotenko
  • 1,393
  • 2
  • 16
  • 27
  • Have you tried making a script (bash/bat etc.) that runs them all then just running the script? – Harmelodic Mar 17 '16 at 09:46
  • Or installed [this plugin?](https://plugins.jetbrains.com/plugin/7248?pr=idea) Not sure how trustworthy/good it is, but it exists for this purpose... – Harmelodic Mar 17 '16 at 09:48
  • @Harmelodic yes, the script is a good option but i felt like there should be a solution from the box in IDEA. And it does exist :) – ikryvorotenko Mar 17 '16 at 14:26
  • Compound is better for development and out of IDEA, but if you want to stagger start up, as well as possibly automate deployment in the future (through a CI server, etc.), scripting might be a better choice. Or a combination of the two; to maximize the efficiency and advantages of both systems! – Harmelodic Mar 17 '16 at 14:30

10 Answers10

31

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.

Stephane Nicoll
  • 31,977
  • 9
  • 97
  • 89
  • 2
    Thanks, that works perfectly. The only question i have on my mind is if there's a way to add some delay or tell one service to wait until another's up. For instance, i have config-service which is required for other ones other and i want to make sure that all my dependent services won't fail because the config is still getting up. – ikryvorotenko Mar 17 '16 at 14:23
  • Thank you, you're beautiful! Much quicker fix compared to a gradle script which creates an executable jar and runs each of them separately...annoyingly time consuming to figure out when each app is in different modules... – Arsalan Khalid Nov 11 '18 at 17:26
15

Update April 2016:

Multirun Plugin says: Prefer to use built-in support starting from 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.

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.

Multirun Plugin

See here for more info about how to setup: https://github.com/rkhmelyuk/multirun/wiki/How-to-run-configurations-with-Multirun

dustin.schultz
  • 13,076
  • 7
  • 54
  • 63
  • Very helpful answer. Just a note, if you are trying to set delay (let's say 10 seconds), set it like "10", not like "10,0" since it will not apply it. – Mts Jun 28 '22 at 08:16
2

Update April 2018:

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

2

Env:

  • IntelliJ IDEA 2021.1.3 (Ultimate Edition)

Steps:

  • Go to Run configurations combo box.
  • Click Edit Configurations....
  • Check Allow parallel run option.
  • Click OK.
Dmitry Rakovets
  • 557
  • 1
  • 6
  • 15
1

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

1

Another note to reduce ambiguity: What was called Run Dashboard in a lot of sources in the past is now called Services.

enter image description here

yuranos
  • 8,799
  • 9
  • 56
  • 65
1

it's called allow parallel run as of 2018.3 instead of Single instance only

usertest
  • 2,140
  • 4
  • 32
  • 51
1
  1. Package the application using mvn package.
  2. Go to the folder where the packaged application jar is stored
  3. Run java -jar [NAME_OF_THE_APPLICATION_JAR] --server.port=[DESIRED_PORT_NUMBER]

OR

  1. Go to the application root directory
  2. Run: mvn spring-boot:run -Drun.arguments="--server.port=[DESIRED_PORT_NUMBER]

That way you can start multiple instances of the same microservice at the same time using different port numbers.

0

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.

2.Add server.port =9999 in application.properties. Run the application.

Now browse Eureka dashboard, you will have 2 instances running.

rahulnikhare
  • 1,362
  • 1
  • 18
  • 25
0

You can go to edit configuration, allow multiple instance and add VM option where you can specify your port

for eg: -Dserver.port=8001