使用spring Boot 3.2时出现依赖性FileSystemNotFoundException

nbysray5  于 5个月前  发布在  Spring
关注(0)|答案(1)|浏览(97)

我最近尝试从spring-boot 3.1.6更新到3.2.0,遇到了以下问题:

java.lang.ExceptionInInitializerError: null
at ai.picovoice.porcupine.Porcupine$Builder.build(Porcupine.java:242)
...
Caused by: java.nio.file.FileSystemNotFoundException: null
at jdk.zipfs/jdk.nio.zipfs.ZipFileSystemProvider.getFileSystem(ZipFileSystemProvider.java:156)
at jdk.zipfs/jdk.nio.zipfs.ZipFileSystemProvider.getPath(ZipFileSystemProvider.java:142)
at java.base/java.nio.file.Path.of(Path.java:209)
at java.base/java.nio.file.Paths.get(Paths.java:98)
at ai.picovoice.porcupine.Utils.getResourceDirectory(Utils.java:58)
at ai.picovoice.porcupine.Utils.<clinit>(Utils.java:39)
... 28 common frames omitted

字符串
我试图找出依赖项在哪里尝试这样做,发现了类似于这样的东西:

private static Path getResourceDirectory() throws RuntimeException {
    URL resourceURL = Porcupine.class.getProtectionDomain().getCodeSource().getLocation();

    Path resourcePath;
    try {
      resourcePath = Paths.get(resourceURL.toURI());
    } catch (URISyntaxException var4) {
      resourcePath = Paths.get(resourceURL.getPath());
    }

    if (resourcePath.toString().endsWith(".jar")) {
      try {
        resourcePath = extractResources(resourcePath);
      } catch (IOException var3) {
        throw new RuntimeException("Failed to extract resources from Porcupine jar.");
      }
    }

    return resourcePath.resolve("porcupine");
  }

  private static Path extractResources(Path jarPath) throws IOException {
    String extractionDirName = jarPath.getFileName().toString().replace(".jar", "");
    String systemTempDir = System.getProperty("java.io.tmpdir");
    Path resourceDirectoryPath = (new File(systemTempDir, extractionDirName)).toPath();
    if (!Files.exists(resourceDirectoryPath, new LinkOption[0])) {
      try {
        Files.createDirectory(resourceDirectoryPath);
      } catch (IOException var13) {
        logger.severe("Failed to create extraction directory at " + jarPath.toString());
        var13.printStackTrace();
        resourceDirectoryPath = (new File(systemTempDir)).toPath();
      }
    }

    JarFile jf = new JarFile(jarPath.toFile());
    Enumeration<JarEntry> entries = jf.entries();

    while(entries.hasMoreElements()) {
      JarEntry jarEntry = (JarEntry)entries.nextElement();
      String jarEntryName = jarEntry.getName();
      if (jarEntryName.startsWith("porcupine")) {
        Path dstPath;
        if (jarEntry.isDirectory()) {
          dstPath = resourceDirectoryPath.resolve(jarEntryName);
          if (!dstPath.toFile().exists()) {
            Files.createDirectory(dstPath);
          }
        } else {
          dstPath = resourceDirectoryPath.resolve(jarEntryName);
          InputStream is = jf.getInputStream(jarEntry);

          try {
            Files.copy(is, dstPath, new CopyOption[]{StandardCopyOption.REPLACE_EXISTING});
          } catch (Throwable var14) {
            if (is != null) {
              try {
                is.close();
              } catch (Throwable var12) {
                var14.addSuppressed(var12);
              }
            }

            throw var14;
          }

          if (is != null) {
            is.close();
          }
        }
      }
    }

    return resourceDirectoryPath;
  }


我已经像这样解包了依赖项(在3.1.6中它工作了):

<plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <mainClass>net.indexoutofmj.neptune.NeptuneBot</mainClass>
                    <requiresUnpack>
                        <dependency>
                            <groupId>ai.picovoice</groupId>
                            <artifactId>picovoice-java</artifactId>
                        </dependency>
                    </requiresUnpack>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>


但现在似乎失败了...我不知道为什么
有人能帮忙吗?
Thanks in advance

vuv7lop3

vuv7lop31#

好吧,这是一个错误,在Spring Boot 3.2.0,因为3.2.1它的工作,因为它应该

相关问题