About the pit encountered using nacos

Pit encountered in using spring cloud nacos

1. Different versions have different artifactIds

<dependency>
	<groupId>com.alibaba.cloud</groupId>
	<artifactId>spring-cloud-alibaba-dependencies</artifactId>
	<version>2.2.0.RELEASE</version>
	<type>pom</type>
	<scope>import</scope>
</dependency>

In version 2.2.0, the introduction of nacos in the sub-project is like this,

<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-alibaba-nacos-config</artifactId>
</dependency>

In version 2.2.1, the artifactId of the subproject has changed to spring-cloud-starter-alibaba-nacos-config

2. Using version 2.2.0.RELEASE, the project starts an infinite loop

When using the nacos configuration center in the project, the startup project will have the problem of pulling the infinite loop all the time. Just change a version. I am using 2.2.1.RELEASE, so the first problem above will appear.

3. Failed to dynamically update data

My configuration is the same as the official one. When the project starts, I can get the configuration information of the configuration center. After I modify the configuration of the configuration center, the project can monitor the changes of the configuration items, but I print the modified items, It's still the old data. I chased the source code and found that I can get the new configuration data, but why hasn't it been updated. The reason is that I did use **@RefreshScope**. I thought that the automatic refresh configuration was enabled globally, so I added it to the startup class, but this annotation is used on the class where you need to dynamically update data, otherwise it will not be used. will modify the configuration.
insert image description here
Hope to help those who have problems

Guess you like

Origin blog.csdn.net/weixin_33613947/article/details/107017545