我想在运行时选择.properties文件。 microprofile-config是否可以?因此,我不想使用META-INF / microprofile-config.properties,而是要使用外部文件:
%dw 2.0
output application/json
/**
* Updates the value of the specified field If the field doesn't exits it will be inserted at the bottom. Use this function with `with`. The with will receive the old value
*/
fun update(objectValue: Object, fieldName: String) =
(newValueProvider: (oldValue: Any, index: Number) -> Any) -> do {
if(objectValue[fieldName]?)
objectValue mapObject ((value, key, index) ->
if(key ~= fieldName)
{(key): newValueProvider(value, index)}
else
{(key): value}
)
else
objectValue ++ {(fieldName): newValueProvider(null, 0)}
}
/**
* Updates the value at the specified index. If the index is bigger than the size it will be appended. Use this function with `with`. The with will receive the old value
*/
fun update(arrayValue: Array, indexToUpdate: Number) =
(newValueProvider: (oldValue: Any, index: Number) -> Any) -> do {
if(arrayValue[indexToUpdate]?)
arrayValue map ((value, index) ->
if(index == indexToUpdate)
newValueProvider(value, index)
else
value
)
else
arrayValue << newValueProvider(null, 0)
}
---
payload update "entities" with (
$ update 0 with (
$ update "sourceEnt" with (
$ update "entity" with (
$ update "OrgAddr" with (
$ map ((item, index) -> item update "MainAddr" with ($ ++ {"StateCode": null}) )
) ++ {
"Flag" : "yes"
}
)
)
)
)
我知道,可以编写自定义配置源,但是我想知道是否有内置选项来定义配置文件,从而避免在每个项目中重复代码
答案 0 :(得分:0)
The web site告诉我们三个选项:
System.getProperties()
System.getenv()
META-INF/microprofile-config.properties
。除了这些,您还可以注册ConfigSources
。
您没有想要的内置选项。