久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術(shù)文章
文章詳情頁

SpringBoot 多Profile使用與切換方式

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

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

文件名格式:application-{profile}.properties可以建立多個(gè)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 (未指定時(shí)默認(rèn)使用的配置)server: port: 80激活方式:

yaml中:spring: profiles: active: dev 或properties中:spring.profiles.active=dev運(yùn)行時(shí):

在打包后運(yùn)行的時(shí)候,添加參數(shù):

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

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

web.xml方式

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

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

標(biāo)簽: Spring
相關(guān)文章:
主站蜘蛛池模板: 车险| 平和县| 泌阳县| 洮南市| 高淳县| 固阳县| 松溪县| 衡东县| 高阳县| 家居| 吉木乃县| 科技| 高雄市| 新竹县| 宁乡县| 乐平市| 集安市| 房产| 樟树市| 翼城县| 随州市| 望奎县| 澄迈县| 扬州市| 岳阳市| 子洲县| 林西县| 磐石市| 长乐市| 福安市| 孟津县| 盐津县| 兴隆县| 海兴县| 青铜峡市| 互助| 怀来县| 万源市| 那坡县| 宁国市| 克东县|