关于springboot 配置文件中属性变量引用方式@@解析
作者:BeALittleCat 时间:2023-12-08 21:50:03
这种属性应用方式是
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;
}
来源:https://blog.csdn.net/u011672034/article/details/79130001
标签:springboot,配置,属性,变量,@@
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
java异步编程之一文看完其异步函数表
2021-12-25 10:57:39
java用户管理注册功能 含前后台代码
2022-08-01 12:05:11
![](https://img.aspxhome.com/file/2023/1/132071_0s.jpg)
java如何去除图片中的白色背景
2022-04-17 00:07:14
![](https://img.aspxhome.com/file/2023/8/113508_0s.jpg)
Android倒计时的开始与停止 剩余时分秒的展示
2023-07-20 03:11:31
![](https://img.aspxhome.com/file/2023/7/120167_0s.jpg)
Android 详解沉浸式状态栏的实现流程
2023-12-18 23:03:31
![](https://img.aspxhome.com/file/2023/6/125406_0s.jpg)
java去除字符串中的空格、回车、换行符、制表符的小例子
2022-04-13 12:33:44
深入了解Java虚拟机栈以及内存模型
2022-02-17 13:37:50
![](https://img.aspxhome.com/file/2023/0/112420_0s.jpg)
Android编程实现下载图片及在手机中展示的方法
2023-10-26 12:30:59
![](https://img.aspxhome.com/file/2023/8/139158_0s.png)
C#中常用的运算符总结
2023-10-10 04:09:32
C#模拟http 发送post或get请求的简单实例
2023-11-05 13:32:18
C# XML操作类分享
2022-02-16 03:22:03
Java如何实现单链表的增删改查
2021-09-19 09:49:25
Java类加载器和类加载机制实例分析
2021-07-18 03:32:26
SpringBoot打jar包遇到的xml文件丢失的解决方案
2023-04-11 23:39:06
![](https://img.aspxhome.com/file/2023/4/66174_0s.png)
C++实现softmax函数的面试经验
2023-06-16 02:07:47
![](https://img.aspxhome.com/file/2023/1/66321_0s.png)
java使用正则抓取网页邮箱
2022-12-02 10:30:30
![](https://img.aspxhome.com/file/2023/1/102001_0s.png)
idea的easyCode的 MybatisPlus模板的配置详解
2022-04-18 21:01:29
spring-boot @Component和@Bean的区别详解
2023-06-28 16:10:36
探讨:将两个链表非降序合并为一个链表并依然有序的实现方法
2023-06-23 01:41:38
springboot表单提交之validator校验
2023-05-16 23:19:17
![](https://img.aspxhome.com/file/2023/4/81324_0s.png)