1
0
mirror of https://gitee.com/mirrors/Spring-Cloud-Alibaba.git synced 2021-06-26 13:25:11 +08:00

[enhance issue #1492 ]Improved nacos configuration parsing, based on PropertySourceLoader---check

This commit is contained in:
zkzlx
2020-06-18 18:28:25 +08:00
parent c07701d98e
commit 5135916175
19 changed files with 365 additions and 168 deletions

View File

@@ -65,9 +65,11 @@ class UserConfig {
private int age;
private String name;
private String hr;
private Map<String, Object> map;
private List<User> users;
public int getAge() {
@@ -112,18 +114,16 @@ class UserConfig {
@Override
public String toString() {
return "UserConfig{" +
"age=" + age +
", name='" + name + '\'' +
", map=" + map +
", hr='" + hr + '\'' +
", users=" + JSON.toJSONString(users) +
'}';
return "UserConfig{" + "age=" + age + ", name='" + name + '\'' + ", map=" + map
+ ", hr='" + hr + '\'' + ", users=" + JSON.toJSONString(users) + '}';
}
public static class User {
private String name;
private String hr;
private String avg;
public String getName() {
@@ -152,13 +152,11 @@ class UserConfig {
@Override
public String toString() {
return "User{" +
"name='" + name + '\'' +
", hr=" + hr +
", avg=" + avg +
'}';
return "User{" + "name='" + name + '\'' + ", hr=" + hr + ", avg=" + avg + '}';
}
}
}
@Component
@@ -215,7 +213,6 @@ class SampleRunner implements ApplicationRunner {
@RefreshScope
class SampleController {
@Autowired
UserConfig userConfig;
@@ -238,7 +235,7 @@ class SampleController {
}
@RequestMapping("/get/{name}")
public String getValue(@PathVariable(value = "name")String name) {
public String getValue(@PathVariable String name) {
return String.valueOf(environment.getProperty(name));
}

View File

@@ -20,7 +20,6 @@ import com.alibaba.cloud.examples.service.EchoService;
/**
* @author lengleng
* @date 2019-08-01
* <p>
* sentinel 降级处理
*/
@@ -35,7 +34,7 @@ public class EchoServiceFallback implements EchoService {
/**
* 调用服务提供方的输出接口.
* @param str 用户输入
* @return
* @return String
*/
@Override
public String echo(String str) {

View File

@@ -22,7 +22,6 @@ import org.springframework.stereotype.Component;
/**
* @author lengleng
* @date 2019-08-01
*/
@Component
public class EchoServiceFallbackFactory implements FallbackFactory<EchoServiceFallback> {

View File

@@ -24,7 +24,6 @@ import org.springframework.web.bind.annotation.PathVariable;
/**
* @author lengleng
* @date 2019-08-01
* <p>
* example feign client
*/

View File

@@ -22,7 +22,6 @@ import org.springframework.web.bind.annotation.RestController;
/**
* @author lengleng
* @date 2019-08-01
*/
@RestController
public class EchoController {