Last active
December 1, 2020 00:37
-
-
Save billydh/d247421e672175cdfd3ffe21900e6b9f to your computer and use it in GitHub Desktop.
Spring Value constructor level
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
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