1. 程式人生 > >springboot 獲取外部配置

springboot 獲取外部配置

獲取外部配置
Properties properties=new Properties()
//xx.properties  絕對路徑獲取
properties.load(new FileInputStream(new File("xx.properties")));
//獲取配置
properties.getProperty("config")

//獲取classpath 目錄下的配置

        Properties prop=new Properties();
        org.springframework.core.io.Resource resource=new ClassPathResource("url.properties");

        prop=PropertiesLoaderUtils.loadProperties(resource);