spring boot 读取配置文件的方法
1 将属性写到主配置文件中applacation.properties
直接使用使用@Value注解(spring提供的spel语法)
@Value("${image.localDir}")
private String localdir;
2 单独写配置文件(例如:image.properties)
1>先扫描到读取配置文件
@PropertySource(value ="classpath:/image.properties",encoding="UTF-8")
2> 读取配置文件中的值
@Value("${image.localDir}")
private String localdir;

浙公网安备 33010602011771号