'How to make IntelliJ recognize multiple application properties as being Spring configurations?
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:
- Invalidate cache and restart
- Inject languages and references
- Look in project structure to add the files again somehow
- Delete all generated files and rebuild project from POM
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.
Solution 1:[1]
Try: https://www.jetbrains.com/help/idea/spring-boot.html#custom-configuration-files (Custom configuration files)
Solution 2:[2]
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.
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 | k-wasilewski |
| Solution 2 | maxeh |
