當(dāng)前位置:首頁 > IT技術(shù) > 移動平臺 > 正文

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/

開通會員,享受整站包年服務(wù)立即開通 >