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);

猜你喜欢

转载自blog.csdn.net/smile06211114/article/details/84400260