springcloud使⽤nacos配置中⼼
创建NACOS配置
Data ID: 配置⽂件名,格式为 <spring.fig.prefix>[-spring.profiles.active].<spring.fig.file-extension>
Group: 分组,<spring.up>
依赖
<dependencies>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>${spring-cloud-alibaba.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
配置springcloud和springboot
spring:
application:
name: sample-nacos1
profiles:
active: dev
cloud:
nacos:
config:
server-addr: 127.0.0.1:8848
# 默认前缀为${spring.application.name}
prefix: ${spring.application.name}
# 默认配置⽂件扩展名为properties
file-extension: yml
# 默认名空间为public
namespace: public
# 默认组为DEFAULT_GROUP
group: SAMPLE_NACOS
效果
⽇志显⽰到了配置⽂件