Read Properties File in Spring with Kotlin

import java.util.Properties
import org.springframework.util.ResourceUtils

object Configuration {
    private val properties: Properties = Properties()

    val databaseHost: String?
    val databaseName: String?
    val databaseUser: String?
    val databasePassword: String?
    val securitySecret: String

    init {
        val file = ResourceUtils.getFile("")
        val stream = FileInputStream(file)
        databaseHost = properties.getProperty("")
        databaseName = properties.getProperty("")
        databaseUser = properties.getProperty("database.user")
        databasePassword = properties.getProperty("database.password")
        securitySecret = properties.getProperty("security.secret")!!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.