springboot-yml文件字符串换行问题解决方案

*.yml文件换行

#security白名单接口
security:
  ignoring: /swagger-resources,/swagger-resources/**,/configuration/ui,/configuration/security,/swagger-ui.html,/webjars/**,/doc.*,/favicon.*,/v2/**,/service-worker.js,/aaa/file/**

这一行太长了,想换行

那就加上"", 在换行的地方加上\就可以了

#security白名单接口
security:
  ignoring: "/swagger-resources,/swagger-resources/**,/configuration/ui,/configuration/security,/swagger-ui.html,\
  /webjars/**,/doc.*,/favicon.*,/v2/**,/service-worker.js,/aaa/file/**,/aaa/strategy/getStrategyDetail"

重启生效

回答: SpringBoot在启动加载配置文件时,默认会加载application.yml或application.properties文件,如果没有明确指定spring.profiles.active属性。\[1\]如果你的项目是一个SpringBoot项目而不是SpringCloud项目,只会识别application.yml配置文件,不会读取bootstrap.yml/properties文件。\[2\]如果想在SpringBoot项目使用bootstrap.yml配置,需要添加依赖spring-cloud-context。\[2\]在yml文件,key: value的冒号后面需要有一个空格。\[3\]如果想让SpringBoot加载自定义的yml配置文件,可以使用@PropertySource注解和@Value注解来指定目标属性在yml文件的全限定名。同时,需要将目标类标记为@Component,以将其实例化到Spring容器。\[3\] #### 引用[.reference_title] - *1* *2* [springcloud+springboot框架 动态加载配置文件 bootstrap.yml/properties文件](https://blog.csdn.net/qq_40448069/article/details/124929353)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [Springboot加载自定义yml文件配置的方法](https://blog.csdn.net/u010922732/article/details/91048606)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值