'Unused properties in IntelliJ

I am having a problem with IntelliJ inspection: It is indicating that all of my properties are unused (see the image). This is untrue, because all my properties all correctly used in spring boot project. I am using IntelliJ Community Edition 2016.1.4

unused properties image



Solution 1:[1]

If you want to ignore all warnings in a specific file. We just have to add this at the first line :

# suppress inspection "UnusedProperty" for whole file

If you just want to ignore a warning for a single property, you can add this line before the property :

# suppress inspection "UnusedProperty"

popup menu to suppress warning text to add to suppress warning for whole file

Solution 2:[2]

Idea -> Preferences -> search "unused" or "Inspections" -> uncheck "Unused Property " under "Properties Files"

Solution 3:[3]

Maybe the plugin is not supporting this feature/annotation which Intellij is then able to resolve. But you could write your own method for that.

So you have to create a method which calls the method which is not capable of creating the connection. The created method has to make us of the @PropertyKey Annotation which will allow Intellij to see the connection for your method and resolve the not used problem you have.

    private static final String BUNDLE_NAME = "application";

    public static void newMethod(@PropertyKey(resourceBundle = BUNDLE_NAME) String key) {
        oldMethod(key) //replace oldMethod with your method
    }

By calling the method foo it will detect the property connection to the property file if your resources are allocatable.

newMethod("your.awesome.key")

Solution 4:[4]

Use final String variable to define the property's key REGION_CONFIG_KEY, Invoke the property's key in @Value("${" + REGION_CONFIG_KEY + "}", So the problem will be fixed

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
Solution 2 Kane.Sun
Solution 3 nikiforovpizza
Solution 4 Aqib Javed