Intellij IDEA complains cannot resolve spring boot properties but they work fine

后端 未结 5 616
囚心锁ツ
囚心锁ツ 2020-12-24 00:31

Can not resolve configuration property \'...

I have no problem accessing my properties through the @Value annotation or through

5条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-24 00:31

    A Gradle-based workaround is this:

    afterEvaluate {
        val kaptKotlinTasks = tasks.named("kaptKotlin") {
            doLast {
                val kaptKotlin = this
                tasks.named("processResources") {
                    from(kaptKotlin.outputs) {
                        include("META-INF/spring-configuration-metadata.json")
                    }
                }
            }
        }
        tasks.named("processResources") {
            this.dependsOn(kaptKotlinTasks)
        }
    }
    

    After running a build (or just the processResources task) from the Intellij Gradle panel, the warnings about the properties should disappear.

    Not ideal, but IntelliJ not supporting kapt is not ideal either :-/

提交回复
热议问题