SpringBoot里面通过配置文件读取文件夹路径

新建实体类,来对应配置文件里面的属性

package com.hzdimi.loan.web.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties(prefix = “dimiapp”)
public class AppSettings {
private String uploadpath;
public String getUploadpath() {
return uploadpath;
}
public void setUploadpath(String uploadpath) {
this.uploadpath = uploadpath;
}
}

在SpringBoot启动里面配置

package com.hzdimi.loan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import com.hzdimi.loan.service.system.SystemService;
import com.hzdimi.loan.utils.SpringContextUtil;
import com.hzdimi.loan.web.config.AppSettings;
@SpringBootApplication
@EnableConfigurationProperties({AppSettings.class})         //此处
public class LoanAppRun {
public static void main(String[] args) throws Exception {
SpringApplication.run(new Object[] { LoanAppRun.class }, args);
SystemService systemService = (SystemService) SpringContextUtil.getBean(“systemService”);
systemService.loadDicMap();
}
}


​配置文件夹路径,在参数配置文件里面

dimiapp.uploadpath=C:/eclipse_work/

你可能感兴趣的:(SpringBoot里面通过配置文件读取文件夹路径)