当前位置:网站首页>NACOS配置中心设置配置文件
NACOS配置中心设置配置文件
2022-08-05 05:25:00 【用户昵称23】
在nacos配置中心新增配置
登录nacos后 配置列表点击 加号
编辑配置信息 提交
其中注意Data ID 的命名规则
${prefix}-${spring.profile.active}.${file-extension}
- prefix 默认为所属工程配置spring.application.name 的值(即:nacos-provider),
也可以通过配 置项 spring.cloud.nacos.config.prefix来配置。
- spring.profiles.active=dev 即为当前环境对应的 profile。 注意:当 spring.profiles.active 为空时,
对应的连接符 - 也将不存在,dataId 的拼接格式变成 ${prefix}.${file-extension}
- file-exetension 为配置内容的数据格式,可以通过配置项 spring.cloud.nacos.config.fileextension 来配置。
目前只支持 properties 和 yaml 类型。
根据你本地的配置文件类型选择 对应后缀
粘贴对应配置信息点击发布即可
springboot 配置文件的 加载顺序
这里主要是说明application和bootstrap的加载顺序。
bootstrap.yml(bootstrap.properties)先加载
application.yml(application.properties)后加载
bootstrap.yml 用于应用程序上下文的引导阶段。
bootstrap.yml 由父Spring ApplicationContext加载。 父ApplicationContext 被加载到使用 application.yml 的之前。
(2)配置区别 bootstrap.yml 和application.yml 都可以用来配置参数。
bootstrap.yml 可以理解成系统级别的一些参数配置,这些参数一般是不会变动的。
application.yml 可以用来定义应用级别的。
我们项目中使用bootstrap.yml 配置文件
#配置中心地址
spring:
cloud:
nacos:
config:
server-addr: 127.0.0.1:8848
#spring.profiles.active=dev
# 该配置影响统一配置中心中的dataId
application:
name:
service-statistics
# 命名空间
#spring.cloud.nacos.config.namespace=8c7d4e34-09df-405f-a351-50fa42285a7f
注意如果本地使用的bootstrap.yml 则nacos中的配置文件必须也是 yml 的类型否则不会被加载到,同理如果是 bootstrap.properties 则nacos 中的配置文件也必须是 properties 否不会被加载到 ,根据 dataId的后缀和新增配置中的选择
先自我介绍一下,小编13年上师交大毕业,曾经在小公司待过,去过华为OPPO等大厂,18年进入阿里,直到现在。深知大多数初中级java工程师,想要升技能,往往是需要自己摸索成长或是报班学习,但对于培训机构动则近万元的学费,着实压力不小。自己不成体系的自学效率很低又漫长,而且容易碰到天花板技术停止不前。因此我收集了一份《java开发全套学习资料》送给大家,初衷也很简单,就是希望帮助到想自学又不知道该从何学起的朋友,同时减轻大家的负担。添加下方名片,即可获取全套学习资料哦
边栏推荐
- LeetCode刷题记录(2)
- H5开发调试-Fiddler手机抓包
- Chengyun Technology was invited to attend the 2022 Alibaba Cloud Partner Conference and won the "Gathering Strength and Going Far" Award
- Operation and maintenance engineer, come and pick up the wool
- BIO, NIO, AIO practical study notes (easy to understand theory)
- RAID disk array
- 七种让盒子水平垂直居中的方法
- In-depth Zabbix user guide - from the green boy
- 路由器和静态路由的配置
- Mina's long and short connections
猜你喜欢
摆脱极域软件的限制
Take you in-depth understanding of cookies
Wireshark packet capture and common filtering methods
RAID disk array
What?CDN cache acceleration only works for accelerating static content?
错误类型:反射。ReflectionException:无法设置属性“xxx”的“类”xxx”与价值“xxx”
Problems encountered in installing Yolo3 target detection module in Autoware
selenium learning
transport layer protocol
input详解之文件上传
随机推荐
教您简单几步实现工业树莓派正确安装RS232转USB驱动
Successful indie developers deal with failure & imposters
time complexity and space complexity
The size of the screen adaptation
sql server duplicate values are counted after
el-autocomplete使用
Tencent greetings function SCF - entry instructions
DevOps-了解学习
js dynamically get screen width and height
[Problem has been resolved]-Virtual machine error contains a file system with errors check forced
Tencent Cloud Message Queue CMQ
markdown editor template
The future of cloud gaming
Four ways to obtain Class objects through reflection
input detailed file upload
transport layer protocol
网络层协议介绍
Passing parameters in multiple threads
Operation and maintenance engineer, come and pick up the wool
LeetCode练习及自己理解记录(1)