ConfigurationProperties无法将yml或properties中的内容读取到bean解决方法

81 字
1 分钟
ConfigurationProperties无法将yml或properties中的内容读取到bean解决方法

注意:读取到静态属性中 springboot无法通过给静态变量赋值在对应字段的set方法去掉static即可

//这两个注解必不可少
@Component
@ConfigurationProperties(prefix = "test")
public class TestConfig
{
/** 验证码类型 */
private static String captchaType;
public static String getCaptchaType() {
return captchaType;
}
public void setCaptchaType(String captchaType) {
TestConfig.captchaType = captchaType;
}
}

文章分享

如果这篇文章对你有帮助,欢迎分享给更多人!

ConfigurationProperties无法将yml或properties中的内容读取到bean解决方法
https://czxcly.cn/posts/configurationproperties无法将yml或properties中的内容读取到bean解决方法/
作者
启源学社
发布于
2022-03-28
许可协议
CC BY-NC-SA 4.0

评论区

Profile Image of the Author
启源学社
公告
欢迎来到我的博客!
音乐
封面

音乐

暂未播放

0:00 0:00
暂无歌词
分类
标签
站点统计
文章
45
分类
2
标签
16
总字数
16,178
运行时长
0
最后活动
0 天前

文章目录