成人在线亚洲_国产日韩视频一区二区三区_久久久国产精品_99国内精品久久久久久久

您的位置:首頁技術文章
文章詳情頁

SpringBoot 多Profile使用與切換方式

瀏覽:3日期:2023-03-18 18:15:47

SpringProfile對不同環境提供不同配置功能的支持,可以通過激活、指定參數等方式快速切換環境。

文件名格式:application-{profile}.properties可以建立多個properties(yaml)文件來不斷的切換

application-dev.properties

server.port=8082

application-prod.properties

server.port=8083

application.properties

server.port=8081spring.profiles.active=dev

SpringBoot 多Profile使用與切換方式

文件名格式:application-{profile}.yaml

server: port: 8082spring: profiles: active: dev---spring: profiles: devserver: port: 8083---spring: profiles: prodserver: port: 8084---spring: profiles: default (未指定時默認使用的配置)server: port: 80激活方式:

yaml中:spring: profiles: active: dev 或properties中:spring.profiles.active=dev運行時:

在打包后運行的時候,添加參數:

java -jar spring-boot.jar --spring.profiles.active=dev;

tomcat 中 catalina.bat(.sh中不用“set”) 添加JAVA_OPS。通過設置active選擇不同配置文件:set JAVA_OPTS='-Dspring.profiles.active=test'

web.xml方式

spring.profiles.active prod標注方式(junit單元測試非常實用)@ActiveProfiles({“dev”})

到此這篇關于SpringBoot 多Profile使用與切換方式的文章就介紹到這了,更多相關SpringBoot 多Profile使用與切換內容請搜索好吧啦網以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持好吧啦網!

標簽: Spring
相關文章: