'Could not find Spring Profile when uses JUnit Runner in IDEA

I'm trying to run a JUnit Test in IntelliJ IDEA, but the Runner could not find the Spring Profile.

this message is displayed in the log:

--spring.profiles.active=dev

but right after:

Could not find key 'spring.profiles.active' in any property source

and at the end the profile used is default

This is where I'm trying to set the profile in IntelliJ:

enter image description here



Solution 1:[1]

I find the problem. Everything works when I remove the "--" of the Environment variables.

This: --spring.profiles.active

To: spring.profiles.active

Solution 2:[2]

Under "Build and run" --> "Environment variables:", add:

SPRING_PROFILES_ACTIVE=[profile name]

Ex:

SPRING_PROFILES_ACTIVE=testing

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Victor Soares
Solution 2 m4ng0o