springboot项目启动多个实例的方法

我现在需要实现这样的功能:将一个服务提供者启动多个实例,下面我列出在eclipse中启动多个实例的方法:

首先看一下我的服务提供者的项目文件结构:

springboot默认的配置文件是application.properties,注意看我为了实现启动多个实例改成两个配置文件,这两个配置文件分别设成不同的端口,这里我列出一个配置文件的内容

application-inst1.properties:

# server_config
server.port=8082
server.servlet.context-path=/news-offer

spring.application.name:news-offer
eureka.client.serviceUrl.defaultZone:http://localhost:8088/news-server/eureka

接下来需要修改启动的NewsOfferApplication.java的方式:

进入Debug Configurations:

在Arguments一栏的Program arguments项填写:--spring.profiles.active=inst1

这个inst1对应的就是application-inst1.properties配置文件名称的inst1,然后再复制一个Configurations,改成inst2,然后分别启动,就OK了~

猜你喜欢

转载自www.cnblogs.com/modou/p/10363541.html