spring-bootgradleintellij-ideapropertiesspring-boot-configuration

How to get Intellij to recognize properties in application.yml


I am trying to get Intellij to recognize my properties using gradle. I have followed the steps here. So this means I have a @ConfigurationProperties annotated class with some properties.

I added the spring dependency to process them:

dependencies {
    optional "org.springframework.boot:spring-boot-configuration-processor"
}

compileJava.dependsOn(processResources)

I added the plugin (I've tried not using the plugin and just making it a compile dependency, no change)

buildscript {
    repositories {
        maven { url 'http://repo.spring.io/plugins-release' }
    }
    dependencies { classpath 'io.spring.gradle:propdeps-plugin:0.0.9.RELEASE' }
}

apply plugin: 'propdeps'
apply plugin: 'propdeps-maven'
apply plugin: 'propdeps-idea'

When I run the build, I see a build/classes/java/main/META-INF/spring-configuration-metadata.json file is created based off of my properties. When I try to use the property in either application.yml or application.properties, Intellij says it cannot resolve it.

The docs does say it should be called additional-spring-configuration-metadata.json and may expect it to be called that to process it, but I do not see a way to make the build name it that way nor configure Intellij to expect otherwise.

Has anyone got this working with gradle? Or is this a bug.

Edit I created a repo with a pair of projects to demonstrate this. One for gradle and one for maven. I created the projects from start.spring.io and basically just added the properties configuration. I also used a straight compile dependency in both cases instead of optional / compileOnly.

I had not confirmed this before, but the code assist does work for maven, but not gradle. Both create a spring-configuration-metadata.json in the META-INF in their respective build folders. I am not exactly sure who is not picking it up.

Misc relevant versions

Intellij: 2017.3.4
Springboot: 1.5.9
Gradle: 4.4.1
Java: 8.161

Solution