Passing active profile to spring bootRun task
I am using IntelliJ Ultimate Version 2019.3.
I am aware that IntelliJ's Run/Debug Configurations dialog of 'Spring Boot' allows 'Active' Profiles' to be set.
This question is about setting active profile through gradle plugin's bootRun task.
Setting environment variable of
SPRING_PROFILES_ACTIVE=dev
in the Run/Debug Configuration of gradle's [bootRun] task gets the job done in successfully setting the active profile.
With the following section in build.gradle
bootRun {
systemProperties = System.properties
}
and also setting IntelliJ bootRun Configuration of
VM options: -Dspring.profiles.active=dev
active profile is successfully set.
The command line option
$ gradle bootRun --args='--spring.profiles.active=dev'
works as expected in setting active profile. But, attempting the equivalent IntelliJ bootRun Configuration of
Arguments: --args'--spring.profiles.active=dev'
or
Arguments: --spring.profiles.active=dev
does not execute underlying bootRun task and instead gives this start and stop task message:
12:26:19 PM: Executing task 'bootRun --spring.profiles.active=dev'...
12:26:19 PM: Task execution finished 'bootRun --spring.profiles.active=dev'.
Any configuration option set for 'bootRun' task through the pull down menu next to the hammer icon(whose mouse over is
Build Project Ctrl + F9) for some reason does not carry over when I double click on the 'bootRun' task inside the Gradle
Tool menu which can be expanded from the top right of the IntelliJ screen. An active profile set in the configuration does
not get picked up when double clicking on the 'bootRun' task inside the Gradle Tool menu.
Please sign in to leave a comment.
Please attach screenshot of the Gradle Run/Debug Configuration that gats executed.
Please try to specify profile as shown here and execute this run configuration. Does it work?
When setting bootRun args as specified in the link above and in screenshot below
I do see the arguments being passed in 'Run' window
10:00:53 AM: Executing tasks 'bootRun --args='spring.profiles.active=dev''...
but the set profile does not kick in
10:00:58.309 [main] INFO sftp.client.SftpClientApp - No active profile set, falling back to default profiles: default
In the example by the provided link notice the -- in front of the args parameter: