JavaWeb ---読みの.properties設定ファイル

あなたは、いくつかの揮発性の構成パラメータが必要
に置かれた後、XML設定ファイルや設定ファイルのプロパティ。

[この方法でのみ、設定ファイルのクラスパスを読み取ることができます]:ベースClassLoderは、設定ファイルを読み込みます

	Properties properties = new Properties();
	
    // 使用ClassLoader加载properties配置文件生成对应的输入流
    InputStream in = PropertiesMain.class.getClassLoader().getResourceAsStream("config/config.properties");
  
    // 使用properties对象加载输入流
    properties.load(in);
    
    //获取key对应的value值
    properties.getProperty(String key);
公開された16元の記事 ウォン称賛12 ビュー4833

おすすめ

転載: blog.csdn.net/weixin_45881192/article/details/104089175