gpt4 book ai didi

java - Spring Boot super JAR : cannot be resolved to absolute file path because it does not reside in the file system

转载 作者:行者123 更新时间:2023-12-04 00:03:50 24 4
gpt4 key购买 nike

将 Spring Boot 版本 1.5.7.RELEASE 导出到可运行的 JAR 后,出现以下错误。由于安全原因,我不使用 maven,并且我在构建路径中添加了所有 JAR。

我在命令下运行

java -jar mailer.jar

然后我收到了你在屏幕截图中看到的错误

enter image description here

最佳答案

因为当打包的 uber-jar 中不存在您的资源时,类路径有问题。使用这样的解决方案

String fuu = "";
ClassPathResource classPathResource = new ClassPathResource("static/foo.txt");
try {
byte[] binaryData = FileCopyUtils.copyToByteArray(classPathResource.getInputStream());
fuu = new String(binaryData, StandardCharsets.UTF_8);
} catch (IOException e) {
e.printStackTrace();
}

关于java - Spring Boot super JAR : cannot be resolved to absolute file path because it does not reside in the file system,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53184517/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com