Назначьте путь к содержимому jar файлов AIML - PullRequest
0 голосов
/ 17 апреля 2020

Мне нужно передать путь к файлам AIML, но когда я нахожусь в IDE, путь равен C:\Development\Test\src\main\resources, а когда я генерирую .jar, путь меняется на file:/C:/Development/Test/SoniatV2-1.0.0.jar!/BOOT-INF/classes!/ Но с .jar вы надеваете не вижу файлов, хотя я добавляю путь /src/main/resources, что я делаю не так? Большое спасибо.

Это мой код:

  private String getResourcePath(){
    // TODO: Into the .jar
    // With this code: file:/C:/Desarrollo/Test/SoniatV2-1.0.0.jar!/BOOT-INF/classes!/
    // String botPath = this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath();

    // TODO:  into the IDE (Intellij Idea)
    // With this code: C:\Desarrollo\Test\src\main\resources
    String resourcesPath = "";
    File currDir = new File(".");
    String path = currDir.getAbsolutePath();
    path = path.substring(0, path.length() -2);
    logger.info(path);
    resourcesPath = path + File.separator + "src" + File.separator + "main" + File.separator + "resources";
    return resourcesPath;
  }

enter image description here

enter image description here

...