随笔 - 524  文章 - 1  评论 - 292  阅读 - 33万

@ConfigurationProperties(prefix = “xx.xx.xx“) 从配置文件中取值赋给类的属性

@ConfigurationProperties(prefix = “xx.xx.xx“) 从配置文件中取值赋给类的属性

@ConfigurationProperties(prefix = “xx.xx.xx”)该注解的作用是从配置文件中取值赋给类的属性,当然也可以为方法的变量赋值

复制代码
/**
 * 服务访问URL
 */
@Component
@ConfigurationProperties(value = "my.service.url")
@Data
public class MyServiceProperties {

    private String appServer;
    private String member;
    private String doOrder;
    private String orderPhoto;  //图片服务
}
复制代码

Apollo配置
my.service.url.appServer = http://xxx1
my.service.url.member = http://xxx2
my.service.url.doOrder = http://xxx3
my.service.url.orderPhoto = http://xxx4

posted on   oktokeep  阅读(44)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· Blazor Hybrid适配到HarmonyOS系统
· 万字调研——AI生成内容检测
· 解决跨域问题的这6种方案,真香!
· Obsidian + DeepSeek:免费 AI 助力你的知识管理,让你的笔记飞起来!
· 一套基于 Material Design 规范实现的 Blazor 和 Razor 通用组件库
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示