Run 15 Springboot services in a predefined order in a single click
已回答
I am using the latest & greatest IntelliJ IDEA: 2023.3.2 (Ultimate Edition).
Currently, when I need to test run my microservices based development, I manually start, one by one, each Springboot service, waiting for the previous one to complete its start.
I find this is error-prone and time-consuming. Is there a way to automate this in IntelliJ IDEA?
请先登录再写评论。
Hello, dbatno. Could you please specify how exactly you start the services? Do you use Run configurations? If so, you can use the Before Launch task to do it; please check the details here.
Yes,I use Run configurations.
The `Before Launch task` method works but it invokes the “before task” multiple times if it is specified as such for multiple other services. How can I avoid this?
Thank you
dbatno, does it help if you add all configurations you need to start to the Before Launch of the last one that should be started?
No, adding all configurations I need to start to the Before Launch of the last one that should be started. is irrelevant in my situation, because the sequence of my Run configurations is a bit different:
C1 C2 C3 C4 C5 C6 C7 C8 - they can all start in parallel
C9 must start after C5 Start completed
C10 must start after C9 Start completed
Attempting to “chain” C5 > C9 > C10 using the `Before Launch task` method, results in C5 being instantiated 3 times… which is an illegal state in the system. There should only be one instance of C5 running.
Does IntelliJ IDEA support “reusing” an existing instance of a Springboot service?
We also have a Compound run configuration for the ones that could be started parallel. Does it help if you set up the Compound run configuration with C1 C2 C3 C4 C6 C7 C8 C10 and add C5 and C9 as Before launch tasks for the C10?
Thanks Olga for introducing Compound to me. It only helps in the sense that C5 doesn't start after C9 and C10. However, after the entire C1 C2 C3 C4 C5 C6 C7 C8 starts, C9 and C10 don't start at all.
Moreover, if I start C9 manually, it automatically starts another instance of C5, which is not what I want.
And if I start C10 manually, it automatically starts another instance of C9, which fails shortly after.
I think that I will abandon the “Before launch task” feature for now, since it has side effects that don't suite my needs.
dbatno, thank you for the update.
It seems your setup is much more complex than it looks like on the first sight. Is it convenient for you to create a request in our YouTrack using this draft? You can describe your Run configurations there in more detail, and my colleagues responsible for Spring could suggest a better solution.