zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    Http状态吗504问题复盘
    Http状态码502问题复盘
    Nginx服务的基本配置
    mysql修改root密码
    centos7开启80端口及其他端口
    tp5隐藏入口文件(基于nginx)
    使nginx支持pathinfo模式
    laravel-admin 上传图片过程中遇到的问题
    Maven介绍
    java中泛型
  • 原文地址:https://www.cnblogs.com/tonggc1668/p/9469899.html
Copyright © 2011-2022 走看看