1

I am new to spring and trying to use Spring Initilizr for my project. I am using the code that was generated by this tool after adding dependencies for 'Spring Web' and 'Spring Data Redis'. When I open the generated code in IntelliJ and try to edit the file application.properties, I notice that everything I type there is grayed out. According to IntelliJ it is an 'unused property'.

Any idea how to enable application.properties in my project?

michael
  • 530
  • 4
  • 16
  • 1
    You're doing fine, Spring will pick it up if you use the property. InteliJ doesn't always get it right for unused properties. – Essex Boy Jan 10 '22 at 14:19
  • It also depends if you have IntelliJ Community or Ultimate, since AFAIK only Ultimate brings all the Spring/Spring Boot plugins, which would enable such IDE features. – dunni Jan 10 '22 at 16:11
  • I am using Community Edition – michael Jan 10 '22 at 16:25
  • I am seeing this with Ultimate Edition. All the properties are greyed out, not just the 'unused' ones. I disabled the plugin and they immediately lit up again and my + click works again – Nicholas Terry Apr 05 '22 at 23:01

2 Answers2

0

As it was mentioned in one of the comments, it is indeed an issue with InteliJ. The properties are working as expected, IntelliJ for some reason doesn't display it correctly.

michael
  • 530
  • 4
  • 16
  • Not sure why is this accepted as an answer. The properties are clearly not used as I can tell as I get error saying that property is not set even though I have the property set in the file and it shows as grayed and unused – pixel Jul 10 '22 at 17:54
0

I see that the answer is accepted; but do not see the solution provided explicitly. In the event it helps others, the property file will be read even if it is greyed out or says "unused property". But if you want the color coded keys, this is what I did to make Intellij recognize the application properties file.

Option-1) Recomplile application.properties under Build -> Recomplile 'application.properties' https://i.stack.imgur.com/I6MXc.png

Option-2) Invalidate cache under File -> Invalidate Caches with IDE restart

Rebuild the project with either of these options and see if the file is recognized.

Zsolo
  • 1