下载nacos 配置中心

pom.xml  依赖

<dependency>
    <groupId>com.alibaba.boot</groupId>
    <artifactId>nacos-config-spring-boot-starter</artifactId>
    <version>0.2.1</version>
</dependency>

nacos 配置中心

application.properties

nacos.config.server-addr=127.0.0.1:8848

启动类:

nacos 配置中心

@SpringBootApplication
@NacosPropertySource(dataId = "springboot2-nacos-config", autoRefreshed = true)
@RestController
public class DemoApplication {

    public static void main(String[] args) {
        System.out.println("12312");
        new ArrayList<>();
        SpringApplication.run(DemoApplication.class, args);
    }
    @NacosValue(value = "${nacos.test.propertie:123}", autoRefreshed = true)
    private String testProperties;

    @GetMapping("/test")
    public String test(){
        return testProperties;
    }

}

访问 127.0.0.1:8080/test     

nacos 配置中心

 

 

 

nacos控制中心

nacos 配置中心

 

修改下值 再次访问

nacos 配置中心

 

相关文章: