• getResourceAsStream properties


     try (InputStream is = getClass().getResourceAsStream("/test.properties")) {
          Properties properties = new Properties();
          properties.load(is);
          ps=new PropertiesPropertySource("main", properties);
        } catch (IOException e) {
          log.error("Something went wrong", e);
        }
     private String getPomPerpertiesPath() {
        String classPath = getClass().getClassLoader().getResource("").getPath();
        String aString = "classes/";
        String targetPath = classPath.substring(0, classPath.lastIndexOf(aString));
        StringBuilder sb = new StringBuilder();
        sb.append(targetPath).append("maven-archiver/pom.properties");
        return sb.toString();
      }*/
      private Properties getProperties(InputStream is) throws IOException {
        Properties properties = new Properties();
        properties.load(is);
        log.info("All defined properties: {}", properties);
        return properties;
      }
      private Properties getProperties(String fileName) throws IOException {
        try (InputStream is = new FileInputStream(new File(fileName))) {
          Properties properties = new Properties();
          properties.load(is);
          log.info("All defined properties: {}", properties);
          return properties;
        }
     System.out.println(getClass().getClassLoader().getResource(""));
     System.out.println(getClass().getClassLoader().getResource("").getPath());
     System.out.println(getClass().getResource(""));
     System.out.println(getClass().getResource("").getPath());
    
    file:/C:/Users/lt32806/git/tempest/tempest-app/tempest-app-report/target/classes/
    /C:/Users/lt32806/git/tempest/tempest-app/tempest-app-report/target/classes/
    file:/C:/Users/lt32806/git/tempest/tempest-app/tempest-app-report/target/classes/com/citi/simpliciti/tempest/report/
    /C:/Users/lt32806/git/tempest/tempest-app/tempest-app-report/target/classes/com/citi/simpliciti/tempest/report/

    https://blog.csdn.net/wws921104/article/details/72637050/
    http://riddickbryant.iteye.com/blog/436693

  • 相关阅读:
    IE的if条件判断
    嵌套div的margin-top不生效
    DocumentFragment对象
    javascript严格模式
    某视频网站下载分析
    c# winform 视频转字符动画
    asp.net mvc 5 蛋疼的问题
    asp.net mvc 防止重复提交
    easyHOOK socket send recv
    C# 之泛型详解
  • 原文地址:https://www.cnblogs.com/tonggc1668/p/9469899.html
Copyright © 2020-2023  润新知