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

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

SpringBoot 多Profile使用與切換方式

瀏覽:11日期: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運行時:

在打包后運行的時候,添加參數(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)文章:
主站蜘蛛池模板: 陆丰市| 手游| 南召县| 宁都县| 渭南市| 许昌县| 扶绥县| 瓮安县| 大化| 安西县| 漳平市| 永兴县| 南昌县| 台前县| 景宁| 清远市| 昌都县| 灵石县| 仁寿县| 定州市| 唐河县| 渭南市| 久治县| 鸡东县| 宁明县| 庆城县| 台北市| 锡林郭勒盟| 阳西县| 邵东县| 织金县| 金阳县| 华阴市| 阿坝县| 胶南市| 华蓥市| 沈阳市| 松原市| 曲松县| 临澧县| 五家渠市|