[英]How to configure spring profiles in Netbeans?
I am running a Spring boot Java app in Netbeans 9.0 which has two profiles (test, production).我在Netbeans 9.0 中运行Spring boot Java 应用程序,它有两个配置文件(测试、生产)。 I need to run the project in 'test' profile instead of the 'default'
我需要在“测试”配置文件而不是“默认”配置文件中运行项目
I have tried the following setups我尝试了以下设置
Setup 1设置 1
Project (Right click) > Properties > Run > Arguments项目(右键单击)> 属性> 运行> 参数
-Dspring.profiles.active=test
Setup 2设置 2
Project (Right click) > Properties > Actions > Run Projects > Activate Profiles项目(右键单击)> 属性> 操作> 运行项目> 激活配置文件
test
The configuration doesn't work correctly and I am getting the following message配置无法正常工作,我收到以下消息
"No active profile set, falling back to default profiles: default" “没有设置活动配置文件,回退到默认配置文件:默认”
Could you please help me to set up this configuration你能帮我设置这个配置吗
After poking around a bit, I found that from Netbeans 8.1 and up you can do the following to set a Spring profile:经过一番探索,我发现从 Netbeans 8.1 及更高版本开始,您可以执行以下操作来设置 Spring 配置文件:
Right click your application -> Run Maven -> Goals -> In the "Properties" section set:右键单击您的应用程序 -> 运行 Maven -> 目标 -> 在“属性”部分设置:
-Dspring.profiles.active={your profile name here}
This worked for me.这对我有用。
Have you tried configuring profiles in the application.properties
or application.yml
in your spring boot app?您是否尝试过在 Spring Boot 应用
application.yml
的application.properties
或application.yml
中配置配置文件?
Please read this documentation Spring Boot Profiles请阅读此文档Spring Boot Profiles
I suppose you have installed this plugin to NetBeans.我想您已经在 NetBeans 中安装了这个插件。
Then right click on the Project -> Properties:然后右键单击项目-> 属性:
Important : The argument starts with "--" (not "-D") since it's a spring boot command.重要提示:参数以“--”(不是“-D”)开头,因为它是一个spring boot 命令。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.