国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

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

SpringBoot 多Profile使用與切換方式

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

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

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

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。通過(guò)設(shè)置active選擇不同配置文件:set JAVA_OPTS='-Dspring.profiles.active=test'

web.xml方式

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

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

標(biāo)簽: Spring
相關(guān)文章:
主站蜘蛛池模板: 郸城县| 玉树县| 陇南市| 安阳县| 安图县| 林西县| 花垣县| 化隆| 盱眙县| 鸡泽县| 宜春市| 太白县| 古浪县| 池州市| 靖安县| 咸宁市| 渝北区| 溧阳市| 上杭县| 大石桥市| 克东县| 大邑县| 华安县| 文昌市| 卓资县| 香格里拉县| 百色市| 峨山| 镶黄旗| 无为县| 固始县| 招远市| 东山县| 蓬莱市| 扎兰屯市| 壶关县| 达尔| 衡阳县| 巴马| 大余县| 定远县|