diff --git a/nutzboot-core/src/main/java/org/nutz/boot/config/impl/YamlConfigureLoader.java b/nutzboot-core/src/main/java/org/nutz/boot/config/impl/YamlConfigureLoader.java
index 55bffea7..41ffc6c8 100644
--- a/nutzboot-core/src/main/java/org/nutz/boot/config/impl/YamlConfigureLoader.java
+++ b/nutzboot-core/src/main/java/org/nutz/boot/config/impl/YamlConfigureLoader.java
@@ -10,10 +10,7 @@ import org.nutz.log.Log;
import org.nutz.log.Logs;
import org.yaml.snakeyaml.Yaml;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
+import java.io.*;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
@@ -61,7 +58,7 @@ public class YamlConfigureLoader extends AbstractConfigureLoader {
// 加载指定profile,如果有的话
if (conf.has("nutz.profiles.active")) {
String profile = conf.get("nutz.profiles.active");
- String _path = path.substring(0, path.lastIndexOf('.')) + "-" + profile + ".yml";
+ String _path = path.substring(0, path.lastIndexOf('.')) + "-" + profile + ".yaml";
readYamlPath(_path);
}
// 如果conf内含有nutz.boot.configure.yaml.dir配置,则读取该目录下的所有配置文件
@@ -87,7 +84,7 @@ public class YamlConfigureLoader extends AbstractConfigureLoader {
if (Strings.isBlank(conf.get("app.build.version"))) {
InputStream ins = resourceLoader.get("build.version");
if (ins != null) {
- yamlToProperties(new Yaml().loadAs(Streams.utf8r(ins), Map.class));
+ conf.load(new InputStreamReader(ins), false);
}
}
}
diff --git a/nutzboot-starter/nutzboot-starter-feign/pom.xml b/nutzboot-starter/nutzboot-starter-feign/pom.xml
index 279a2ca1..7b5c9f59 100644
--- a/nutzboot-starter/nutzboot-starter-feign/pom.xml
+++ b/nutzboot-starter/nutzboot-starter-feign/pom.xml
@@ -60,17 +60,22 @@
com.netflix.ribbon
ribbon-loadbalancer
- 2.2.4
+ 2.7.18
com.netflix.ribbon
ribbon-core
- 2.2.4
+ 2.7.18
+
+
+ com.netflix.ribbon
+ ribbon-archaius
+ 2.7.18
com.netflix.ribbon
ribbon-eureka
- 2.2.4
+ 2.7.18
provided
diff --git a/nutzboot-starter/nutzboot-starter-nacos-config/src/main/java/org/nutz/boot/starter/nacos/NacosConfigureLoader.java b/nutzboot-starter/nutzboot-starter-nacos-config/src/main/java/org/nutz/boot/starter/nacos/NacosConfigureLoader.java
index 6c7cfecc..ae7125d1 100644
--- a/nutzboot-starter/nutzboot-starter-nacos-config/src/main/java/org/nutz/boot/starter/nacos/NacosConfigureLoader.java
+++ b/nutzboot-starter/nutzboot-starter-nacos-config/src/main/java/org/nutz/boot/starter/nacos/NacosConfigureLoader.java
@@ -1,40 +1,27 @@
package org.nutz.boot.starter.nacos;
-import static com.alibaba.nacos.api.PropertyKeyConst.ACCESS_KEY;
-import static com.alibaba.nacos.api.PropertyKeyConst.CLUSTER_NAME;
-import static com.alibaba.nacos.api.PropertyKeyConst.CONFIG_LONG_POLL_TIMEOUT;
-import static com.alibaba.nacos.api.PropertyKeyConst.CONFIG_RETRY_TIME;
-import static com.alibaba.nacos.api.PropertyKeyConst.CONTEXT_PATH;
-import static com.alibaba.nacos.api.PropertyKeyConst.ENABLE_REMOTE_SYNC_CONFIG;
-import static com.alibaba.nacos.api.PropertyKeyConst.ENCODE;
-import static com.alibaba.nacos.api.PropertyKeyConst.ENDPOINT;
-import static com.alibaba.nacos.api.PropertyKeyConst.ENDPOINT_PORT;
-import static com.alibaba.nacos.api.PropertyKeyConst.MAX_RETRY;
-import static com.alibaba.nacos.api.PropertyKeyConst.NAMESPACE;
-import static com.alibaba.nacos.api.PropertyKeyConst.SECRET_KEY;
-import static com.alibaba.nacos.api.PropertyKeyConst.SERVER_ADDR;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-import java.util.concurrent.Executor;
-
+import com.alibaba.nacos.api.NacosFactory;
+import com.alibaba.nacos.api.config.ConfigService;
import org.nutz.boot.AppContext;
import org.nutz.boot.annotation.PropDoc;
-import org.nutz.boot.config.impl.PropertiesConfigureLoader;
import org.nutz.ioc.impl.PropertiesProxy;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
+import org.nutz.json.Json;
+import org.nutz.json.JsonFormat;
import org.nutz.lang.Lang;
import org.nutz.lang.Strings;
import org.nutz.lang.stream.StringInputStream;
import org.nutz.lang.util.NutMap;
import org.nutz.log.Log;
import org.nutz.log.Logs;
+import org.yaml.snakeyaml.Yaml;
-import com.alibaba.nacos.api.NacosFactory;
-import com.alibaba.nacos.api.config.ConfigService;
+import java.io.IOException;
+import java.util.*;
+import java.util.concurrent.Executor;
+
+import static com.alibaba.nacos.api.PropertyKeyConst.*;
/**
* @author wentao
@@ -45,8 +32,8 @@ import com.alibaba.nacos.api.config.ConfigService;
* @email wizzer.cn@gmail.com
* @date 2019-03-06 21:45
*/
-@IocBean
-public class NacosConfigureLoader extends PropertiesConfigureLoader {
+@IocBean(create = "init")
+public class NacosConfigureLoader {
/**
* 获取日志对象
*/
@@ -111,13 +98,16 @@ public class NacosConfigureLoader extends PropertiesConfigureLoader {
@Inject
protected AppContext appContext;
-
+
+ @Inject
+ private PropertiesProxy conf;
+
protected ConfigService configService;
private List configListenerList;
public void addConfigListener(ConfigListener configListener) {
- if(null == configListenerList) {
+ if (null == configListenerList) {
configListenerList = new ArrayList<>();
}
configListenerList.add(configListener);
@@ -127,6 +117,10 @@ public class NacosConfigureLoader extends PropertiesConfigureLoader {
if ("json".equals(contentType)) {
NutMap configMap = new NutMap(content);
conf.putAll(configMap);
+ } else if ("yaml".equals(contentType)) {
+ Map result = new HashMap<>();
+ buildFlattenedMap(result, new Yaml().loadAs(content, Map.class), "");
+ conf.putAll(result);
} else if ("xml".equals(contentType)) {
Properties properties = new Properties();
try {
@@ -144,37 +138,69 @@ public class NacosConfigureLoader extends PropertiesConfigureLoader {
throw Lang.makeThrow("nacos.config.data_type is not found or not recognize,only json,xml and properties are support!");
}
}
-
+
+ private void buildFlattenedMap(Map result, Map source, String path) {
+ for (Map.Entry entry : source.entrySet()) {
+ String key = Strings.sNull(entry.getKey());
+ if (Strings.isNotBlank(path)) {
+ if (key.startsWith("[")) {
+ key = path + key;
+ } else {
+ key = path + "." + key;
+ }
+ }
+ Object value = entry.getValue();
+ if (value instanceof Map) {
+ @SuppressWarnings("unchecked")
+ Map map = (Map) value;
+ buildFlattenedMap(result, map, key);
+ } else if (value instanceof Collection) {
+ @SuppressWarnings("unchecked")
+ Collection