Last active
July 14, 2022 15:11
-
-
Save artemptushkin/ac63c4f60850fd5cbf808fd9ae2b9e9b to your computer and use it in GitHub Desktop.
kotlin-spring-configuration-properties-best-practices
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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