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

}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM