当前位置:首页 > IT技术 > 移动平台 > 正文

Java SpringBoot手动加载指定application.properties
2021-09-08 11:42:37

封装方法

public class Application {
    public static void main(String[] args) throws IOException {
        FileInputStream inputStream = new FileInputStream(new File(System.getProperty("user.dir")) + "\config\application.properties");
        Properties properties = new Properties();
        properties.load(inputStream);
        inputStream.close();
        SpringApplication application = new SpringApplicationBuilder(Application.class).build();
        application.setDefaultProperties(properties);
        application.run(args);
    }
}

本文摘自 :https://www.cnblogs.com/

开通会员,享受整站包年服务立即开通 >