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

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

SpringBoot 多Profile使用與切換方式

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

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

文件名格式: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 (未指定時默認(rèn)使用的配置)server: port: 80激活方式:

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

在打包后運(yùn)行的時候,添加參數(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單元測試非常實用)@ActiveProfiles({“dev”})

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

標(biāo)簽: Spring
相關(guān)文章:
主站蜘蛛池模板: 朝阳县| 聂荣县| 越西县| 平山县| 敦煌市| 成安县| 曲阳县| 静安区| 上饶市| 都昌县| 广宁县| 崇义县| 石狮市| 巴林左旗| 绥宁县| 阿拉尔市| 天镇县| 武强县| 西和县| 鹤庆县| 湘潭市| 海伦市| 梧州市| 徐闻县| 东乡县| 开封县| 修文县| 新疆| 高碑店市| 巴林左旗| 顺平县| 普定县| 蕲春县| 新乡市| 镇沅| 杭锦后旗| 长沙市| 临高县| 南丹县| 剑川县| 黄龙县|