先看个例子:
spring: application: name: cms-discovery-eureka-ha --- spring: profiles: peer1 server: port: 9092 eureka: instance: hostname: peer1 client: serviceUrl: defaultZone: http://peer2:9093/eureka/ --- spring: profiles: peer2 server: port: 9093 eureka: instance: hostname: peer2 client: serviceUrl: defaultZone: http://peer1:9092/eureka/
使用方式:假如生成的包名为 cms-eureka-ha.jar
java -jar cms-eureka-ha.jar --spring.profiles.active=peer1
java -jar cms-eureka-ha.jar --spring.profiles.active=peer2
通过spring.profiles.active指定使用哪个profile启动。
推荐文章:https://my.oschina.net/u/2278977/blog/807958