spring: datasource: url: jdbc:mysql://127.0.0.1:3306/wxdd?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8&useSSL=false driver-class-name: com.mysql.cj.jdbc.Driver username: root password: 123456 jpa: show-sql: true server: #打的war包名 context-path: /sell
1.yml支持多文檔塊方式
server: port: 8081 spring: profiles: active: prod --- server: port: 8083 spring: profiles: dev --- server: port: 8084 spring: profiles: prod #指定屬於哪個環境
2.properties配置文件
properties配置文件中占位符
1、隨機數
${random.value}、${random.int}、${random.long} ${random.int(10)}、${random.int[1024,65536]}
2、占位符獲取之前配置的值,如果沒有可以是用:指定默認值
person.last-name=張三${random.uuid} person.age=${random.int} person.birth=2017/12/15 person.boss=false person.maps.k1=v1 person.maps.k2=14 person.lists=a,b,c person.dog.name=${person.hello:hello}_dog //若是前面的配置沒有取到person.hello的值,則默認為hello person.dog.age=15
3.配置文件加載順序是根據文件的位置來定義的
–file:./config/ –file:./ –classpath:/config/ –classpath:/ 優先級由高到底,高優先級的配置會覆蓋低優先級的配置; SpringBoot會從這四個位置全部加載主配置文件;**互補配置**;