在Kotlin/Java中寻找类似Spring的.properties和y.y(a)ml文件的属性解析器



我正在Kotlin开发库,现在我正在寻找像Spring这样的属性解析程序库,但不想直接使用Spring库。

我不希望库依赖于Spring jar。

你知道一些替代方案吗?

您想读取yaml和属性文件吗?

相关性:

compile "com.fasterxml.jackson.module:jackson-module-kotlin:${jacksonVersion}"
compile "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${jacksonVersion}"
compile "com.fasterxml.jackson.dataformat:jackson-dataformat-properties:${jacksonVersion}"

代码:

// Read ObjectMapper docs to learn about the different config options
val mapper = ObjectMapper(YAMLFactory()).registerKotlinModule()//...
val stream = FileInputStream(File(filename))
mapper.readValue<MyProperties>(stream)

最新更新