How does Intellij detect Spring Profiles?
Hi!
I was reading about Spring profiles in Intellij in https://www.jetbrains.com/help/idea/spring.html
And when I open the Change Active Spring Profiles Dialog I see no profile and: No profiles defined in selected scope.
So the question is what do I need to do to have the profiles detected by Spring?
The module is a Maven Project with Spring boot dependencies and the Spring facet is shown in the module properties.
I'm using IJ 2017.2 for Mac.
Thanks in advance,
Jorge
Please sign in to leave a comment.
Hello,
unfortunately that's a known bug. To make all profiles available, all configuration classes/XML files containing profile definitions must have been opened in editor once. Please watch https://youtrack.jetbrains.com/issue/IDEA-108408 for progress
Hi,
I don't have XML configuration files, just profile specific property/yaml files and non-profile specific classes annotated with @Configuration. I tried opening all of them and nothing changed.
I will wait until that issue is completed to see if that works.
Thanks,
Jorge
Hi again,
That ticket was solved almost one month ago and it solved the issue partially.
I have several projects and see different behaviour:
In one of them, it detects now profiles defined with @Profile but ignores the application-*.properties even though they are mapped to the project. We normally use those application.properties and it would be great if those files are used to figure out the profiles.
In other project, it doesn't detect the @Profile annotations either. This has annotations defined at class level like:
@Profile(IntegrationTest.NAME) and with string literals, and also annotations used on bean definition level.
In this second project, there is no bean or configuration autodetection (ComponentScan) enabled.
I just saw this other ticket related to the change active profiles dialog: https://youtrack.jetbrains.com/issue/IDEA-149680 and it is still not yet solved