![](/img/trans.png)
[英]configure maven profiles in spring boot @activeprofile annotation
[英]How to configure spring profiles in Netbeans?
我在Netbeans 9.0 中運行Spring boot Java 應用程序,它有兩個配置文件(測試、生產)。 我需要在“測試”配置文件而不是“默認”配置文件中運行項目
我嘗試了以下設置
設置 1
項目(右鍵單擊)> 屬性> 運行> 參數
-Dspring.profiles.active=test
設置 2
項目(右鍵單擊)> 屬性> 操作> 運行項目> 激活配置文件
test
配置無法正常工作,我收到以下消息
“沒有設置活動配置文件,回退到默認配置文件:默認”
你能幫我設置這個配置嗎
經過一番探索,我發現從 Netbeans 8.1 及更高版本開始,您可以執行以下操作來設置 Spring 配置文件:
右鍵單擊您的應用程序 -> 運行 Maven -> 目標 -> 在“屬性”部分設置:
-Dspring.profiles.active={your profile name here}
這對我有用。
您是否嘗試過在 Spring Boot 應用application.yml
的application.properties
或application.yml
中配置配置文件?
請閱讀此文檔Spring Boot Profiles
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.