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

nbysray5  于 2024-01-06  发布在  Spring
关注(0)|答案(1)|浏览(211)

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

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

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

  1. private static Path getResourceDirectory() throws RuntimeException {
  2. URL resourceURL = Porcupine.class.getProtectionDomain().getCodeSource().getLocation();
  3. Path resourcePath;
  4. try {
  5. resourcePath = Paths.get(resourceURL.toURI());
  6. } catch (URISyntaxException var4) {
  7. resourcePath = Paths.get(resourceURL.getPath());
  8. }
  9. if (resourcePath.toString().endsWith(".jar")) {
  10. try {
  11. resourcePath = extractResources(resourcePath);
  12. } catch (IOException var3) {
  13. throw new RuntimeException("Failed to extract resources from Porcupine jar.");
  14. }
  15. }
  16. return resourcePath.resolve("porcupine");
  17. }
  18. private static Path extractResources(Path jarPath) throws IOException {
  19. String extractionDirName = jarPath.getFileName().toString().replace(".jar", "");
  20. String systemTempDir = System.getProperty("java.io.tmpdir");
  21. Path resourceDirectoryPath = (new File(systemTempDir, extractionDirName)).toPath();
  22. if (!Files.exists(resourceDirectoryPath, new LinkOption[0])) {
  23. try {
  24. Files.createDirectory(resourceDirectoryPath);
  25. } catch (IOException var13) {
  26. logger.severe("Failed to create extraction directory at " + jarPath.toString());
  27. var13.printStackTrace();
  28. resourceDirectoryPath = (new File(systemTempDir)).toPath();
  29. }
  30. }
  31. JarFile jf = new JarFile(jarPath.toFile());
  32. Enumeration<JarEntry> entries = jf.entries();
  33. while(entries.hasMoreElements()) {
  34. JarEntry jarEntry = (JarEntry)entries.nextElement();
  35. String jarEntryName = jarEntry.getName();
  36. if (jarEntryName.startsWith("porcupine")) {
  37. Path dstPath;
  38. if (jarEntry.isDirectory()) {
  39. dstPath = resourceDirectoryPath.resolve(jarEntryName);
  40. if (!dstPath.toFile().exists()) {
  41. Files.createDirectory(dstPath);
  42. }
  43. } else {
  44. dstPath = resourceDirectoryPath.resolve(jarEntryName);
  45. InputStream is = jf.getInputStream(jarEntry);
  46. try {
  47. Files.copy(is, dstPath, new CopyOption[]{StandardCopyOption.REPLACE_EXISTING});
  48. } catch (Throwable var14) {
  49. if (is != null) {
  50. try {
  51. is.close();
  52. } catch (Throwable var12) {
  53. var14.addSuppressed(var12);
  54. }
  55. }
  56. throw var14;
  57. }
  58. if (is != null) {
  59. is.close();
  60. }
  61. }
  62. }
  63. }
  64. return resourceDirectoryPath;
  65. }


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

  1. <plugin>
  2. <groupId>org.springframework.boot</groupId>
  3. <artifactId>spring-boot-maven-plugin</artifactId>
  4. <configuration>
  5. <mainClass>net.indexoutofmj.neptune.NeptuneBot</mainClass>
  6. <requiresUnpack>
  7. <dependency>
  8. <groupId>ai.picovoice</groupId>
  9. <artifactId>picovoice-java</artifactId>
  10. </dependency>
  11. </requiresUnpack>
  12. </configuration>
  13. <executions>
  14. <execution>
  15. <goals>
  16. <goal>repackage</goal>
  17. </goals>
  18. </execution>
  19. </executions>
  20. </plugin>


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

vuv7lop3

vuv7lop31#

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

相关问题