spring-cloud-starter-alibaba-nacos-config
使用nacos有两个包,这是spring-cloud包。我使用的版本是2.2.6.RELEASE。
具体使用代码不再赘述,一开始启动报错,NoClassDefFoundError:org.springframework.boot.context.properties.ConfigurationBeanFactoryMetadata.java
经查询得知,springboot:2.4.X以上版本删除了这个类。解决办法有两个:
- 自己在项目里建一个这个类,代码从老版本复制过来即可。
- 降低springboot版本,经测试2.3.6.RELEASE可正常使用。
由于我既不想在项目里加一个类也不想降低springboot版本,因此决定尝试其他方法。
nacos-config-spring-boot-start
另一个方法是spring-boot包。网上看到0.2.12版本已解决上面那个问题。
经测试与springboot-2.4.2完美运行,但是过程中踩了一个大坑。
Nacos2. X version compared to 1 X adds grpc communication mode and 2 ports.
Nacos2.x版本相比1.x新增了gRPC的通信方式,增加2个端口
but, the new port is automatically generated with a certain offset based on the primary port.
但是新增端口是在主端口的基础上,进行一定偏移量自动生成
Wh