当前位置:网站首页>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开发全套学习资料》送给大家,初衷也很简单,就是希望帮助到想自学又不知道该从何学起的朋友,同时减轻大家的负担。添加下方名片,即可获取全套学习资料哦
边栏推荐
- Autoware--Beike Tianhui rfans lidar uses the camera & lidar joint calibration file to verify the fusion effect of point cloud images
- 传输层协议
- 用户和用户组管理、文件权限管理
- Come, come, let you understand how Cocos Creator reads and writes JSON files
- product learning materials
- 大小屏适配
- [问题已处理]-jenkins流水线checkout超时
- 错误类型:反射。ReflectionException:无法设置属性“xxx”的“类”xxx”与价值“xxx”
- [问题已处理]-虚拟机报错contains a file system with errors check forced
- DevOps - Understanding Learning
猜你喜欢

Mina的长连接和短连接
time complexity and space complexity

LeetCode中常用语言的一些基本方法记录

DevOps - Understanding Learning

路由器和静态路由的配置

By solving these three problems, the operation and maintenance efficiency will exceed 90% of the hospital

el-autocomplete使用

前置++和后置++的区别
![[问题已处理]-虚拟机报错contains a file system with errors check forced](/img/07/1222a44dd52b359bf7873e6f3b7ebf.png)
[问题已处理]-虚拟机报错contains a file system with errors check forced

滚动条问题,未解决
随机推荐
Mina's long and short connections
错误记录集锦(遇到则记下)
Into the pre-service, thought they play so flowers
Difference between link and @improt
Insight into the general trend of the Internet, after reading this article, you will have a thorough understanding of Chinese domain names
Media query, rem mobile terminal adaptation
Network Troubleshooting Basics - Study Notes
sql server duplicate values are counted after
wc、grep、tar、vi/vim
network issue?Service packet loss?This is enough
selenium学习
VLAN is introduced with the experiment
Detailed explanation of ten solutions across domains (summary)
The use of three parameters of ref, out, and Params in Unity3D
What should I do if the SSL certificate prompts that it is expired or invalid?
VRRP overview and experiment
多线程之传递参数
What is Alibaba Cloud Express Beauty Station?
Network wiring and digital-to-system conversion
Growth: IT Operations Trends Report