import com.alibaba.dubbo.config.ReferenceConfig;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
ReferenceConfig<T> reference = null;
ObjectMapper mapper = new ObjectMapper();
//避免报错,原因 obj 的属性多于 valueType 导致,添加一条语句即可
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
try {
reference = mapper.readValue(jsonValue,new TypeReference<ReferenceConfig<T>>() { });
//转换是会丢失注册地址信息,需要单独在将注册中心地址重新添加到该对象
reference.setRegistries(registries);
} catch (Exception e) {
}
将阿里dubbo的ReferenceConfig<T>对象从缓存中获取出对应的json字符串后,将其转换为ReferenceConfig<T>对象