Skip to content

Instantly share code, notes, and snippets.

@billydh
Created December 1, 2020 00:46
Show Gist options
  • Save billydh/8d540dccfd5b4782be51001fe759df87 to your computer and use it in GitHub Desktop.
Save billydh/8d540dccfd5b4782be51001fe759df87 to your computer and use it in GitHub Desktop.
with constructor injection
package com.thecodebrews.kotlinspringvaluedemo
import org.springframework.beans.factory.annotation.Value
import org.springframework.stereotype.Component
import javax.annotation.PostConstruct
@Component
class StoreConfiguration(
@Value("\${store.no-of-customers-capacity}") val capacity: Int
) {
@Value("\${store.size-in-meter-square}")
val size: Int = 0
@PostConstruct
fun getStoreConfiguration() {
print("Store size is $size meter square\n")
print("Store max capacity is $capacity customers\n")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment