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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<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

1
2
3
4
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

1
2
> curl -X POST "http://192.168.165.240:8848/nacos/v1/cs/configs?dataId=service-provider.properties&group=DEFAULT_GROUP&content=useLocalCache=true"
true
1
2
3
4
5
6
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]
1
2
> curl -X POST "http://192.168.165.240:8848/nacos/v1/cs/configs?dataId=service-provider.properties&group=DEFAULT_GROUP&content=useLocalCache=false"
true
1
2
3
4
5
6
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

1
2
3
4
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

1
2
> curl -X POST "http://192.168.1.20:8848/nacos/v1/cs/configs?dataId=service-provider.yaml&group=DEFAULT_GROUP&content=useLocalCache:%20false"
true
1
2
3
4
5
6
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]
1
2
> curl -X POST "http://192.168.1.20:8848/nacos/v1/cs/configs?dataId=service-provider.yaml&group=DEFAULT_GROUP&content=useLocalCache:%20true
true
1
2
3
4
5
6
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]

Powered by AppBlog.CN     浙ICP备14037229号

Copyright © 2012 - 2020 APP开发技术博客 All Rights Reserved.

访客数 : | 访问量 :