@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 2023-12-24 18:52  oktokeep  阅读(26)  评论(0编辑  收藏  举报