Reputation: 5261
I have been moving around my 'application.properties' file provided by Spring Boot and creating copies in other folders to compare precedence by location.
I noticed that the file lost the icon meaning it was recognized by IntelliJ as a Spring configuration file.
The file
still works fine, but all the spring property references now say: "unused property".
I know some other Questions similar to this solve the "unused property"-message by ignoring them entirely, but then you lose the Spring configuration hinting too.
Isn't there some way to have IntelliJ recognize the file as being Spring configurations again?
I have tried to:
But I haven't found the light yet... Anyone knows how I would go about doing this? It would be nice to be able to mark multiple files, so all the application.proprties files I use will hint at the options for spring configuration.
Upvotes: 2
Views: 4153
Reputation: 1583
I had the same issue after creating a new module in my project and adding an application.properties
to the resource folder. It was shown with the wrong icon and when I started the app, the config was also not used.
It seemed that the spring context was not properly loaded. I noticed that Intellij showed a warning in the SpringBoot application class (the class name was marked yellow). Clicking ALT + Enter
on it and choosing the first option Create SpringBoot facet solved the issue. You will see the project structure dialog and only need to click OK.
Upvotes: 0
Reputation: 5261
Apparently IntelliJ IDEA fails to recognize application.properties if you have several properties-files currently.
A bug report has been created: https://youtrack.jetbrains.com/issue/IDEA-255946
(As a workaround, you need to retain only one application.properties in your resource folder and then reopen this project.)
Upvotes: 0
Reputation: 4623
Try: https://www.jetbrains.com/help/idea/spring-boot.html#custom-configuration-files (Custom configuration files)
Upvotes: 2