@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
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Blazor Hybrid适配到HarmonyOS系统
· 万字调研——AI生成内容检测
· 解决跨域问题的这6种方案,真香!
· Obsidian + DeepSeek:免费 AI 助力你的知识管理,让你的笔记飞起来!
· 一套基于 Material Design 规范实现的 Blazor 和 Razor 通用组件库