SpringBoot多配置文件,切換環境


多配置文件

properties配置方式

 application.properties

#通過active指定選用配置環境
spring.profiles.active=test

application-dev.properties

#開發環境
server.port=8081

application-test.properties

#測試環境
server.port=8082

application-pro.properties

#生產環境
server.port=8083

yml配置方式

 application.yml

#通過active指定選用配置環境
spring:
  profiles:
  active: pro

application-dev.yml

#開發環境
server:
  port: 8081

application-test.yml

#測試環境
server:
  port: 8082

application-pro.yml

#生產環境
server:
  port: 8083

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM