Spring Cloud 集成 Nacos 调试

版本匹配

Spring Boot Version Spring Cloud Version Nacos Version
2.1.X.RELEASE Greenwich.RELEASE 0.2.1.RELEASE
2.0.X.RELEASE Finchley.RELEASE 0.2.0.RELEASE
1.5.X.RELEASE Edgware.RELEASE 0.1.x.RELEASE

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>2.1.6.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>Greenwich.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

properties config

bootstrap.properties

spring.cloud.nacos.config.server-addr=192.168.1.20:8848
spring.application.name=service-provider
#spring.cloud.nacos.config.file-extension=yaml
spring.cloud.nacos.config.file-extension=properties

update config

> curl -X POST "http://192.168.165.240:8848/nacos/v1/cs/configs?dataId=service-provider.properties&group=DEFAULT_GROUP&content=useLocalCache=true"
true
Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$bed7de61] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
Loading nacos data, dataId: 'service-provider.properties', group: 'DEFAULT_GROUP'
Located property source: CompositePropertySource {name='NACOS', propertySources=[NacosPropertySource {name='service-provider.properties'}]}
No active profile set, falling back to default profiles: default
Started application in 2.105 seconds (JVM running for 34.992)
Refresh keys changed: [useLocalCache]
> curl -X POST "http://192.168.165.240:8848/nacos/v1/cs/configs?dataId=service-provider.properties&group=DEFAULT_GROUP&content=useLocalCache=false"
true
Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$bed7de61] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
Loading nacos data, dataId: 'service-provider.properties', group: 'DEFAULT_GROUP'
Located property source: CompositePropertySource {name='NACOS', propertySources=[NacosPropertySource {name='service-provider.properties'}]}
No active profile set, falling back to default profiles: default
Started application in 2.234 seconds (JVM running for 60.858)
Refresh keys changed: [useLocalCache]

yaml config

bootstrap.properties

spring.cloud.nacos.config.server-addr=192.168.1.20:8848
spring.application.name=service-provider
spring.cloud.nacos.config.file-extension=yaml
#spring.cloud.nacos.config.file-extension=properties

update config

> curl -X POST "http://192.168.1.20:8848/nacos/v1/cs/configs?dataId=service-provider.yaml&group=DEFAULT_GROUP&content=useLocalCache:%20false"
true
Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$613642c8] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
Loading nacos data, dataId: 'service-provider.yaml', group: 'DEFAULT_GROUP'
Located property source: CompositePropertySource {name='NACOS', propertySources=[NacosPropertySource {name='service-provider.yaml'}]}
No active profile set, falling back to default profiles: default
Started application in 2.238 seconds (JVM running for 252.568)
Refresh keys changed: [useLocalCache]
> curl -X POST "http://192.168.1.20:8848/nacos/v1/cs/configs?dataId=service-provider.yaml&group=DEFAULT_GROUP&content=useLocalCache:%20true
true
Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$613642c8] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
Loading nacos data, dataId: 'service-provider.yaml', group: 'DEFAULT_GROUP'
Located property source: CompositePropertySource {name='NACOS', propertySources=[NacosPropertySource {name='service-provider.yaml'}]}
No active profile set, falling back to default profiles: default
Started application in 2.285 seconds (JVM running for 272.409)
Refresh keys changed: [useLocalCache]
上一篇 Spring Cloud 集成 Nacos
下一篇 Spring Cloud @RefreshScope和@EventListener实现Nacos配置更新监听
目录
文章列表
1 支付宝境外支付商户报备被拒
支付宝境外支付商户报备被拒
2
Bigcommerce支付网关设计
Bigcommerce支付网关设计
3
MySQL 正则表达式
MySQL 正则表达式
4
使用Docker部署Spring Cloud项目
使用Docker部署Spring Cloud项目
5
Prometheus + Grafana 使用 elasticsearch_exporter 监控 ElasticSearch
Prometheus + Grafana 使用 elasticsearch_exporter 监控 ElasticSearch
最新评论
一位WordPress评论者
一位WordPress评论者
2月12日
您好,这是一条评论。若需要审核、编辑或删除评论,请访问仪表盘的评论界面。评论者头像来自 Gravatar。