关于springboot 配置文件中属性变量引用方式@@解析
这种属性应用方式是
field_name=@field_value@。
两个@符号是springboot为替代${}属性占位符产生,原因是${}会被maven处理,所以应该是起不到引用变量的作用。
@@方式可以引用springboot非默认配置文件(即其他配置文件)中的变量;
springboot默认配置文件是
src/main/resources/application.properties
补充知识:springboot项目使用@Value注解获取配置文件中的配置信息
application.yml配置文件得配置信息
web:
my_name: mqs
tags: aaa,bbb,ccc,ddd
like: 学习
使用@Value注解获取配置文件中的配置信息
/**
* TODO springboot配置文件得读取方法一
*/
@Value("${web.tags}")
private String[] tags;
@Value("${web.like}")
private String like;
@Value("${web.my_name}")
private String myName;
@RequestMapping("/web")
public String testValue(){
String str = Arrays.toString(tags) + "----->>>" + like + "----->>>" + myName;
return str;
}
以上这篇关于springboot 配置文件中属性变量引用方式@@解析就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。
相关文章
SpringBoot使用@Cacheable出现预览工具乱码的解决方法
直接使用注解进行缓存数据,我们再使用工具去预览存储的数据时发现是乱码,这是由于默认序列化的问题,所以接下来将给大家介绍一下SpringBoot使用@Cacheable出现预览工具乱码的解决方法,需要的朋友可以参考下2023-10-10
Spring Boot整合Spring Cache及Redis过程解析
这篇文章主要介绍了Spring Boot整合Spring Cache及Redis过程解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下2019-12-12


最新评论