mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
refactor(nacos): Roll back to the original solution to solve the problem of compatibility
This commit is contained in:
@@ -21,7 +21,7 @@ import java.io.StringReader;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import com.alibaba.cloud.nacos.NacosConfigManager;
|
||||
import com.alibaba.cloud.nacos.NacosConfigProperties;
|
||||
import com.alibaba.nacos.api.config.listener.Listener;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -57,14 +57,14 @@ class SampleRunner implements ApplicationRunner {
|
||||
int userAge;
|
||||
|
||||
@Autowired
|
||||
private NacosConfigManager nacosConfigManager;
|
||||
private NacosConfigProperties nacosConfigProperties;
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
System.out.println(
|
||||
String.format("Initial username=%s, userAge=%d", userName, userAge));
|
||||
|
||||
nacosConfigManager.getConfigService().addListener(
|
||||
nacosConfigProperties.configServiceInstance().addListener(
|
||||
"nacos-config-example.properties", "DEFAULT_GROUP", new Listener() {
|
||||
|
||||
/**
|
||||
@@ -108,12 +108,12 @@ class SampleController {
|
||||
Integer age;
|
||||
|
||||
@Autowired
|
||||
private NacosConfigManager nacosConfigManager;
|
||||
private NacosConfigProperties nacosConfigProperties;
|
||||
|
||||
@RequestMapping("/user")
|
||||
public String simple() {
|
||||
return "Hello Nacos Config!" + "Hello " + userName + " " + age + "!"
|
||||
+ nacosConfigManager.getConfigService();
|
||||
+ nacosConfigProperties.configServiceInstance();
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user