Czar
07/29/2019, 12:38 PMplugins {
id("org.springframework.boot") version "2.1.6.RELEASE"
id("io.spring.dependency-management") version "1.0.7.RELEASE"
val kotlinVersion = "1.3.41"
kotlin("jvm") version kotlinVersion
kotlin("plugin.spring") version kotlinVersion
kotlin("kapt") version kotlinVersion
}
dependencies {
kapt("org.springframework.boot:spring-boot-configuration-processor")
implementation(kotlin("reflect"))
implementation(kotlin("stdlib-jdk8"))
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
//...
}
application.yml
security:
csrfEnabled: true
token.writer.secret: h2l89efhlwskiehf89o23fhnsldhf89023
usage of secret
in a class:
@ConfigurationProperties(prefix = "security.token.writer")
class TokenBasedAuthenticationFilter {
private lateinit var secret: String
//...
There is no metadata or autocomplete and IntelliJ shows Cannot resolve configuration property 'security.token.writer.secret'
warning
Am I missing something or is it a bug/limitation?Luis Munoz
07/29/2019, 4:18 PMLuis Munoz
07/29/2019, 4:18 PMLuis Munoz
07/29/2019, 4:19 PMLuis Munoz
07/29/2019, 4:19 PMCzar
07/29/2019, 6:36 PMCzar
07/30/2019, 6:23 AMkotlin-reflect
, it's there. I also re-checked all the requirements in 50.1, all are satisfied. And 50.5 only asks to do what I already have shown in the snippets above. I'll edit and add relevant dependencies to the snippet, to avoid ambiguity.Czar
07/30/2019, 7:43 AM@ConfigurationProperties(prefix = "security")
class SecurityConfigurationParameters {
var csrfEnabled: Boolean = true
@NestedConfigurationProperty
lateinit var token: Token
}
class Token {
lateinit var privateSecret: String
lateinit var publicSecret: String
}
I also tried making Token
an inner class Token
in the SecurityConfigurationProperties
- to no avail. Error is always:
BindException: Failed to bind properties under 'security.token' to com.example.security.Token
IllegalStateException: Unable to get value for property token
Czar
07/30/2019, 8:37 AM@ConfigurationProperties(prefix = "security")
class SecurityConfigurationParameters(
@DefaultValue("false")
val csrfEnabled: Boolean,
@NestedConfigurationProperty
val token: TokenConfig
)
class TokenConfig(
val privateSecret: String,
val publicSecret: String
)