Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set spring active profile environment variable in IntelliJ

I am using spring boot application (maven project) in eclipse. When I run test clean target of maven project, I want to load the active profiles

I have added the property spring.profiles.active=test,aop in application.properties and also in application-test.properties, this does not have any affect.

or setting this property in command line option of IntelliJ IDE as -Dspring.profiles.active=test,aop does not have an effect when the command is test clean. I have also tried setting the JVM argument of the Runner in Intelligent

however @ActiveProfiles("test") works when the test case class is executed from IntelliJ IDE( right click -> run TestCaseClass).

Any clues ?

like image 770
Ayub Avatar asked Dec 20 '16 14:12

Ayub


People also ask

How do I pass an environment variable in IntelliJ?

Add environment variablesFrom the main menu, select Run | Edit Configurations or choose Edit Configurations from the run/debug configurations selector on the toolbar. In the Run/Debug Configurations dialog, select a configuration you want to add the environment variables to.

How do I run Spring Boot apps in IntelliJ?

From the main menu, select Run | Edit Configurations. Select the necessary Spring Boot run configuration to open its settings. Click Modify options. In the list that opens, point to On 'Update' action.

How add Springframework to IntelliJ?

Enable Spring support in IntelliJ IDEAPress Ctrl+Alt+S to open the IDE settings and select Plugins. Open the Installed tab, search for Spring and make sure that the checkboxes next to all relevant plugins are selected.


1 Answers

Setting the VM Options with -Dspring.profiles.active=test

enter image description here

enter image description here

like image 76
Stéphane GRILLON Avatar answered Oct 20 '22 22:10

Stéphane GRILLON