错误问题:‘dependencies.dependency.version‘ for org.springframework.cloud:spring-cloud-starter-openfeign:jar,出现这样问题的原因是因为nacos排除了依赖,需要手动进行添加
<!--nacos服务发现组件-->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-loadbalancer</artifactId>
<version>3.1.1</version>
</dependency>
如何利用nacos做配置中心
1、导入依赖
<!--配置中心-->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
2、编写一个bootstrap.properties
的文件即可
spring.application.name=gulimall-coupon
spring.cloud.nacos.config.server-addr=127.0.0.1:8848
spring.cloud.nacos.config.refresh-enabled=true
# 命名空间做环境的隔离 后面必须跟上nacos的ID
spring.cloud.nacos.config.namespace=d5dce6f2-12d3-4e56-8b77-868c5e06909d