fix(cli): 修复argument和environment为空时报错
This commit is contained in:
@@ -68,19 +68,4 @@ public class ServiceInfoWrapper {
|
||||
", name='" + name + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
private Map<String, Object> escape(Map<String, Object> map) {
|
||||
// https://github.com/spring-projects/spring-framework/issues/9628
|
||||
// spring boot 的配置文件没有办法转义 $,使用 $\{ -> ${ 来绕过一下
|
||||
return map.entrySet()
|
||||
.stream()
|
||||
.peek(entry -> {
|
||||
if (entry.getValue() instanceof String) {
|
||||
String key = entry.getKey();
|
||||
String value = (String) entry.getValue();
|
||||
entry.setValue(value.replace("$\\{", "${"));
|
||||
}
|
||||
})
|
||||
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.lanyuanxiaoyao.service.cli.runner;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -18,6 +19,9 @@ public class SpringPropertiesEscapeHelper {
|
||||
* 使用 _ 代替 map key 的 .
|
||||
*/
|
||||
public static <T> Map<String, T> escapeMapKey(Map<String, T> map) {
|
||||
if (ObjectUtil.isEmpty(map)) {
|
||||
return map;
|
||||
}
|
||||
Map<String, T> result = new HashMap<>();
|
||||
for (Map.Entry<String, T> entry : map.entrySet()) {
|
||||
result.put(entry.getKey().replaceAll("_", "."), entry.getValue());
|
||||
@@ -28,6 +32,9 @@ public class SpringPropertiesEscapeHelper {
|
||||
public static <T> Map<String, T> escapeMapValue(Map<String, T> map) {
|
||||
// https://github.com/spring-projects/spring-framework/issues/9628
|
||||
// spring boot 的配置文件没有办法转义 $,使用 $\{ -> ${ 来绕过一下
|
||||
if (ObjectUtil.isEmpty(map)) {
|
||||
return map;
|
||||
}
|
||||
return map.entrySet()
|
||||
.stream()
|
||||
.peek(entry -> {
|
||||
|
||||
Reference in New Issue
Block a user