springboot 2.0 多环境配置

application.properties多环境配置:

需要多个properties文件:主文件:

spring.profiles.active=test

这个指定当前应用的配置文件为application-test.properties

等于号后面的为application-test.properties文件的-后面的test,可以随意指定名称


application.yaml文件,只需要一个文件

my:
 number: ${random.int}
 name: zhangsan
 address: http://www.${my.name}.com

server:
  port: 8888

spring:
  profiles:
    active: dev

  #duohuanjing
---
spring:
    profiles: dev
server:
    port: 9999
其中---,代表下面的为另一部分。并且第一层命名,得靠到最左边,靠道边。


猜你喜欢

转载自blog.csdn.net/m0_38044453/article/details/80412913