1、定义配置类
@Component
public class FilePathConfig {
public static String httpResUrl;
public static String savePath;
public static String resUri;
public String getHttpResUrl() {
return httpResUrl;
}
@Value("${file.path.httpResURL}")
public void setHttpResUrl(String httpResUrl) {
this.httpResUrl = httpResUrl;
}
public String getSavePath() {
return savePath;
}
@Value("${file.path.SAVE_PATH}")
public void setSavePath(String savePath) {
this.savePath = savePath;
}
public String getResUri() {
return resUri;
}
@Value("${file.path.resURI}")
public void setResUri(String resUri) {
this.resUri = resUri;
}
}
2、在配置文件中配置
#图片存储地址
file:
path:
httpResURL: http://127.0.0.1:18080
SAVE_PATH: /data/images
resURI: /parking_platform/