spring cloud项目通过IDEA启动多实例无法通过active profiles指定端口的问题

1.问题

springcloud项目中,希望通过IDEA的edit configurations中的Active profiles指定端口来启动多实例,结果发现配置一直不生效。配置图如下:
spring cloud项目通过IDEA启动多实例无法通过active profiles指定端口的问题但启动第二个实例时,仍然报端口被占用,可见启动的仍然是application.properties中配置的端口,上图的端口配置并没有生效,报错图如下
spring cloud项目通过IDEA启动多实例无法通过active profiles指定端口的问题

2.解决方案

后来查询了这篇提问,发现原因是spring-cloud-config会覆盖命令行传入的参数,所以在edit configurations并无作用。

要实现多实例启动,需要直接在application.properties中进行修改,将原8071端口改为8072,即可正常启动,附图如下:
spring cloud项目通过IDEA启动多实例无法通过active profiles指定端口的问题
spring cloud项目通过IDEA启动多实例无法通过active profiles指定端口的问题
到此,问题解决