Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save artemptushkin/ac63c4f60850fd5cbf808fd9ae2b9e9b to your computer and use it in GitHub Desktop.
Save artemptushkin/ac63c4f60850fd5cbf808fd9ae2b9e9b to your computer and use it in GitHub Desktop.
kotlin-spring-configuration-properties-best-practices
@Configuration
@EnableConfigurationProperties(ExampleParentProperties::class)
class ExampleConfiguration {}
@ConstructorBinding
@ConfigurationProperties(prefix = "io.github.artemptushkin.example")
data class ExampleParentProperties(
val child: ChildProperties = ChildProperties()
)
data class ChildProperties(
val defaultedStringProperty: String = "default",
val defaultOverriddenProperty: String = "default",
val requiredStringProperty: String,
val optionalStringProperty: String? = null,
val notNullListProperty: List<String> = emptyList()
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment