当前位置:网站首页>Static static member variables use @value injection
Static static member variables use @value injection
2022-06-29 19:33:00 【Why worry about a dream with a Golden hoop】
Use @Value annotation static type
@Component
public class MyConfig {
@Value("${env}")
private static String env;
public static String getEnv() {
return env;
}
public static void setEnv(String env) {
MyConfig.env = env;
}
}
Use the above method ,MyConfig.getEnv() Returns the null
Write it correctly
@Component
public class MyConfig {
private static String env;
public static String getEnv() {
return env;
}
@Value("${env}")
public void setEnv(String env) {
MyConfig.env = env;
}
}
Must be in a non static method setEnv Before using @Value annotation
边栏推荐
- 誰在抖音文玩裏趁亂打劫?
- 【笔记】再笔记--边干边学Verilog HDL – 014
- What if the win11 policy service is disabled? Solution to disabling win11 policy service
- 软件工程专业大二,之前的学习情况不太好该怎么规划后续发展路线
- Arm comprehensive computing solution redefines visual experience and powerfully enables mobile games
- 逻辑结构与物理结构
- Exploration and practice of NLP problem modeling scheme
- swift可选值总结
- Introduction to isalpha () method
- Technical methodology of new AI engine under the data infrastructure upgrade window
猜你喜欢

What about frequent network disconnection of win11 system? Solution to win11 network instability

销量赶不上拿钱速度,威马赴港救急

QC协议+华为FCP+三星AFC快充取电5V9V芯片FS2601应用

@Sneakythlows annotation

KDD 2022 | 协同过滤中考虑表征对齐和均匀性

微信推出图片大爆炸功能;苹果自研 5G 芯片或已失败;微软解决导致 Edge 停止响应的 bug|极客头条

Connaissance générale des paramètres de sécurité du serveur Cloud

JVM(4) 字節碼技術+運行期優化

How important is it to make a silver K-line chart?

习题8 #第8章 Verilog有限状态机设计-4 #Verilog #Quartus #modelsim
随机推荐
JVM (4) bytecode technology + runtime optimization
@SneakyThrows注解
终于,进亚马逊了~
数据基础设施升级窗口下,AI 新引擎的技术方法论
领先11%,华为云天筹AI求解器再度登顶国际权威榜单
构建增强现实移动应用程序的六款顶级工具
细说GaussDB(DWS)复杂多样的资源负载管理手段
The sales volume could not catch up with the speed of taking money. Weima went to Hong Kong for emergency rescue
MBA-day26 数的概念与性质
全局变量和静态变量的初始化
出逃与进军,临期食品的「双面江湖」
深度好文 | YOLOv5+DeepSORT多目标跟踪深入解读与测试(含源码)
Third party tools and framework integration
自动获取本地连接及网络地址修改
Technical methodology of new AI engine under the data infrastructure upgrade window
做白银k线图有多重要?
Common knowledge of ECS security settings
From CIO to Consultant: the transformation of it leaders
打新债线上开户安全吗
Win11安装权限在哪里设置?Win11安装权限设置的方法