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]

版权声明:
作者:Joe.Ye
链接:https://www.appblog.cn/index.php/2023/03/24/spring-cloud-integrate-nacos-debugging/
来源:APP全栈技术分享
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
打赏
海报
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.RELEAS……
<<上一篇
下一篇>>
文章目录
关闭
目 录