bootstrap.yml
spring:
application:
name: cloud-order
profiles:
active: dev
bootstrap-dev.yml
spring:
application:
name: cloud-order-dev
cloud:
nacos:
config:
server-addr: localhost:8848
namespace: 54fdd84f-44bb-45c1-b9c7-2b13bb4dca57
shared-configs:
- data-id: cloud-order.yml
group: DEFAULT_GROUP
refresh: true
- data-id: test.yml
group: DEFAULT_GROUP
refresh: true
依赖
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring-boot.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
<version>${spring-cloud-alibaba.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
<version>${spring-cloud-alibaba.version}</version>
</dependency>
</dependencies>
docker-compose 部署单机 Nacos
version: '3.8'
services:
nacos:
image: nacos/nacos-server
restart: unless-stopped
environment:
- PREFER_HOST_MODE=hostname
- MODE=standalone
volumes:
- ./data/nacos-data:/home/nacos/data
- ./data/nacos-standalone-logs/:/home/nacos/logs
ports:
- "8848:8848"
- "9848:9848"