public class Utils {
    private static Properties props = new Properties();
    
    static {
        ClassLoader classLoader = Utils.class.getClassLoader();
        InputStream inputStream = classLoader.getResourceAsStream("mapping.properties");
        try {
            props.load(inputStream);
        } catch (IOException e1) {
            e1.printStackTrace();
        }
    }
    
    public static String GetString(String key){
        String value = null;
        value = props.getProperty(key);
        return value;
    }
    
}

简易读取properties文件代码,其中properties文件放置在src/main/resources目录下

相关文章:

  • 2022-01-02
  • 2022-12-23
  • 2022-01-19
  • 2022-12-23
  • 2021-05-23
  • 2021-12-19
  • 2021-10-04
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-26
  • 2021-12-20
  • 2021-12-17
相关资源
相似解决方案