本地配置
#微服务配置
spring:
application:
name: content-api # 服务名
cloud:
nacos:
server-addr: 192.168.101.65:8848 # nacos 服务器地址,这个一定放在discovery上面,idea提示是错的
discovery: # 让nacos发现这个服务才配置
namespace: dev402 # 命名空间,在naocs里的
group: xuecheng-plus-project # nacos中的属性
config: # 需要从nacos拉取配置才写
namespace: dev402
group: xuecheng-plus-project
file-extension: yaml
refresh-enabled: true
extension-configs: #拓展配置文件,从其他的配置文件直接继承过来
- data-id: content-service-${spring.profiles.active}.yaml
group: xuecheng-plus-project
refresh: true
shared-configs: # 共享配置文件
- data-id: swagger-${spring.profiles.active}.yaml
group: xuecheng-plus-common
refresh: true
- data-id: logging-${spring.profiles.active}.yaml
group: xuecheng-plus-common
refresh: true
profiles:
active: dev # 重要的,同时dev也是默认值,服务名-active.yaml 是这个文件请求的配置文件
nacos文件配置
文件名:content-service-dev.yaml
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://192.168.101.65:3306/xc402_content?serverTimezone=UTC&userUnicode=true&useSSL=false
username: root
password: mysql
文件名:content-api-dev.yaml
server:
servlet:
context-path: /content
port: 63040
#配置本地优先
spring:
cloud:
config:
override-none: true