Intellij Idea同一spring项目运行多个实例

使用idea工具开发时难免有同一项目运行多个的情况,而idea默认项目是以单例模式运行的若重复运行将会停止上一个进程再重新开启一个,那么如何让同一个项目已不同端口运行呢?

在idea顶部toolbar的run actions中可以选择run/debug configuration来运行不同的项目,我以spring boot的项目为例,配置文件设置端口为8762。

server.port=8762

运行该项目,项目已8762端口正常启动。

2019-01-11 10:06:44.863  INFO 3316 --- [           main] .s.c.n.e.s.EurekaAutoServiceRegistration : Updating port to 8762
2019-01-11 10:06:44.863  INFO 3316 --- [           main] c.e.c.e.EurekaClientApplication          : Started EurekaClientApplication in 8.452 seconds (JVM running for 9.426)

在toolbar栏我们可以看到main class的运行情况。

main class

如果我们还想运行多个实例怎么办呢,在run/debug configuration中打开edit configurations。

edit

将该项目右上角的allow running in parallel(允许并行运行)勾选中然后确定即可。

勾选

然后修改原本项目的配置文件,将端口改为8763,再运行该项目。

server.port=8763

项目将不会停止原本已8762端口运行的相同项目,直接8763端口运行另外一个实例,如图显示运行的项目又增加了一个。

2019-01-11 10:13:53.334  INFO 9036 --- [           main] .s.c.n.e.s.EurekaAutoServiceRegistration : Updating port to 8763
2019-01-11 10:13:53.334  INFO 9036 --- [           main] c.e.c.e.EurekaClientApplication          : Started EurekaClientApplication in 7.914 seconds (JVM running for 8.583)

main class

猜你喜欢

转载自blog.csdn.net/qq_32352777/article/details/86288448