application.yml中写参数
demo:
testFlag: lsl
file:
upload:
suffixPath: /suffixPath
localPath: D:/opt/yglh0330/
类中先注入,再获取
//读取配置文件中的参数
@Value("${demo.testFlag}")
private String testFlag;
@Value("${file.upload.suffixPath}")
private String uploadSuffixPath;
@Value("${file.upload.localPath}")
private String uploadLocalPath;
@ResponseBody
@GetMapping("demo1")
public String demo1(){
return testFlag;
}