IDEA realizes the same startup class and uses different ports to start multiple services

Problem phenomenon:

Today, I encountered a small problem in microservice learning:

How to implement the same startup class to start multiple services using different ports?


problem analysis:

In other words, a ProductApplication startup class has been written , and a service can be started by running this startup class;

But when you run it again, you are not starting another service, but restarting the started service, that is to say, it is in singleton mode!

So how to open multiple services?

it's actually really easy:

Just set it in IDEA's startup class configuration:

1. Edit the startup configuration:

2. Uncheck the Single_instance only  option;

If your IDEA version does not have this option, there should be an Allow parallel run (allowing multiple instances to run) option, then check the option;

Then change the name of this service to avoid the same name as the original one, and then the most important thing: modify the port number (change a port number that is different from the original service);

After the configuration is complete, click apply and click ok, and then run the startup class .


Solution:

Here I use the debug environment to run the startup class,

Successful multi-service startup:

 

Guess you like

Origin blog.csdn.net/weixin_42585386/article/details/109206410