nacos做为配置中心
1.配置pom文件nacos配置依赖
点击查看代码
<!-- nacos-config 依赖-->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
点击查看代码
spring.cloud.nacos.config.server-addr=localhost:8848
#dev环境
spring.cloud.nacos.config.namespace=7a23139c-86d1-4a6b-9f50-69b7ed611512
#dev测试
#spring.cloud.nacos.config.namespace=c99f32c2-af92-4b96-8a00-ea74ecf30cd4
#dev生产
#spring.cloud.nacos.config.namespace=4952e96c-2283-4265-be07-0fdf6b5a9cee
spring.application.name=nacos-config
spring.cloud.nacos.config.file-extension=yaml
spring.cloud.nacos.config.group=TEST_GROUP
spring.profiles.active=info
点击查看代码
#server:
# port: 3377
# servlet:
# context-path: /nacosconfig
#spring:
# application:
# name: nacos-config
# cloud:
# nacos:
# discovery:
# server-addr: localhost:8848
# datasource:
# url: jdbc:mysql://localhost:3306/springcloud?useUnicode=true&characterEncoding=UTF-8&useSSL=false
# username: root
# password: root
# driver-class-name: com.mysql.jdbc.Driver
#rsa:
# publicKey: sfsdds