Skip to content

Instantly share code, notes, and snippets.

@billydh
Last active December 1, 2020 00:37
Show Gist options
  • Save billydh/d247421e672175cdfd3ffe21900e6b9f to your computer and use it in GitHub Desktop.
Save billydh/d247421e672175cdfd3ffe21900e6b9f to your computer and use it in GitHub Desktop.
Spring Value constructor level
package com.thecodebrews.kotlinspringvaluedemo
import org.springframework.beans.factory.annotation.Value
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import javax.annotation.PostConstruct
@SpringBootApplication
class KotlinspringvaluedemoApplication(
@Value("\${application.name}") private val appName: String
) {
@Value("\${store.name}")
val storeName: String = ""
@Value("\${store.address}")
val storeAddress: String = ""
@PostConstruct
fun getStoreInfo() {
println("Store name: $storeName")
println("Store address: $storeAddress")
println("Application name: $appName")
}
}
fun main(args: Array<String>) {
runApplication<KotlinspringvaluedemoApplication>(*args)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment