当前位置:网站首页>静态方法获取配置文件数据
静态方法获取配置文件数据
2022-08-05 03:05:00 【zhanghe_zht】
编写工具类中遇到注入配置文件中的数据读取不到,解决办法
1.工具类要用@Component修饰
2.使用@Value注解将配置文件中的数据注入到普通变量中
3.通过@PostConstruct注解将普通变量赋值给静态变量
通过以上步骤静态方法中就可以获取到配置文件中的数据了
边栏推荐
猜你喜欢
随机推荐
1667. 修复表中的名字
Object.defineProperty monitors data changes in real time and updates the page
[机缘参悟-60]:《兵者,诡道也》-2-孙子兵法解读
Countdown to 2 days|Cloud native Meetup Guangzhou Station, waiting for you!
The linear table lookup
通过模拟Vite一起深入其工作原理
The 22-07-31 weeks summary
Open Source License Description LGPL
QT MV\MVC结构
Tencent Cloud [Hiflow] New Era Automation Tool
Hash table lookup (hash table)
Compressed storage of special matrices
How to sort multiple fields and multiple values in sql statement
Native js realizes the effect of selecting and canceling all the multi-select boxes
链表的简单描述及代码的简单实现
[Storage] Dawning Storage DS800-G35 ISCSI maps each LUN to the server
In 2022, you still can't "low code"?Data science can also play with Low-Code!
Solve connect: The requested address is not valid in its context
mysql没法Execute 大拿们求解
The problem of lack of dynamic library "libtinfo.so.5" in ksql application under UOS system