首先确认你的springboot版本是高于2.4的版本的,然后移除以下依赖
<!-- <dependency>--> <!-- <groupId>org.springframework.cloud</groupId>--> <!-- <artifactId>spring-cloud-starter-bootstrap</artifactId>--> <!-- </dependency>-->
配置中心需要的依赖
<dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> </dependency>
springboot版本2.5.15
<springcloud.version>2021.0.5</springcloud.version> <alibaba.version>2021.0.5.0</alibaba.version>
<!--spring cloud依赖管理,引入了Spring Cloud的版本--> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>${springcloud.version}</version> <type>pom</type> <scope>import</scope> </dependency> <!--SCA --> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-alibaba-dependencies</artifactId> <version>${alibaba.version}</version> <type>pom</type> <scope>import</scope> </dependency>
配置文件
spring: config: import: "optional:nacos:${spring.application.name}-${spring.profiles.active}.yml"
启动成功,自动刷新也具备
标签:springboot,--,spring,bootstrap,alibaba,yml,cloud From: https://www.cnblogs.com/q202105271618/p/18175460