Looking for a cleaner way to access custom propert...
# spring
n
Looking for a cleaner way to access custom properties, seems like
lateinit
is not playing well when spring is reading and initialising properties via
yaml
. I have a class
Copy code
@ConfigurationProperties("maintenance")
class MaintenanceProperties {
var foo : String ? = null 
}
when we change it to => lateinit var foo :     String , kotlin gives us runtime error lateinit property foo has not been initialized
Without
lateinit
The way I am forced to access it is
properties.foo!!
,one way to get rid of
!!
is to perform a null check but this approch doesn't work well when we have nested properties (we end up with ugly null checks). Is there a better way to get rid of
!!
and make the application failed during startup if the property is not defined ?