hutool读取配置文件demo

Hutool名称的由来

Hutool = Hu + tool,是原公司项目底层代码剥离后的开源库,“Hu”是公司名称的表示,tool表示工具。Hutool谐音“糊涂”,一方面简洁易懂,一方面寓意“难得糊涂”。

开发中需要引入的jar

Maven

在项目的pom.xml的dependencies中加入以下内容:

<dependency>
    <groupId>cn.hutool</groupId>
    <artifactId>hutool-all</artifactId>
    <version>5.6.1</version>
</dependency>

Gradle

compile 'cn.hutool:hutool-all:5.6.1'



public static void main(String[] args) {
//resources文件下面的配置文件

ClassPathResource resource = new ClassPathResource("application-dev.properties");
Properties properties = new Properties();
try {
properties.load(resource.getStream());
} catch (IOException e) {
e.printStackTrace();
}
System.out.println(properties.get("url"));

}
posted @ 2021-03-31 16:58  zysnba  阅读(4552)  评论(0)    收藏  举报