profiles 配置详解
生活随笔
收集整理的這篇文章主要介紹了
profiles 配置详解
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
profiles 配置詳解
@Profile(value = "pro")1,為什么要使用 profiles
在開發中,一般有兩種環境
1,生產環境 [項目上線,客戶在使用中,就是生產環境]
2,開發環境[就是開發環境,不解釋]
有時候開發環境和生產環境的配置方法是不一樣的,那么如何快速的切換呢,這里就要
使用 profiles 文件
2,使用方法
1,創建 application-developer.properties
server.port=8081
2,創建 application-product.properties
server.port=8082
3,修改 application.properties
#server.port=8080
spring.profiles.active=developer
4,運行測試
5,總結
在 application.properties 里面激活哪個文件就會使用哪個端口
3,去掉 application.properties 的運行方式
刪除 application.properties
打包
使用 jar -jar 去運行
總結
以上是生活随笔為你收集整理的profiles 配置详解的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: springboot 的两种配置文件语法
- 下一篇: 配置文件加载优先级和外部配置文件加载||