springBoot 读取配置文件yml中的信息

yml中自定义一些变量

var:
  analyze_url: test
  ocr_url: test
  microsoft_key: test

映射到类变量中

@Getter
@Component
public class varModel {
    @Value("${var.analyze_url}")
    private String analyze_url;
    @Value("${var.ocr_url}")
    private String ocr_url;
    @Value("${var.microsoft_key}")
    private String microsoft_key;
}//end

调用方式

注入

    @Autowired
    varModel varModel_;

通过  varModel_ 调用

猜你喜欢

转载自www.cnblogs.com/hcfan/p/9920895.html