简体   繁体   中英

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). I need to run the project in 'test' profile instead of the 'default'

I have tried the following setups

Setup 1

Project (Right click) > Properties > Run > Arguments

-Dspring.profiles.active=test

Setup 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:

Right click your application -> Run Maven -> Goals -> In the "Properties" section set:

-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?

Please read this documentation Spring Boot Profiles

I suppose you have installed this plugin to NetBeans.
Then right click on the Project -> Properties:

在此处输入图片说明

Important : The argument starts with "--" (not "-D") since it's a spring boot command.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM