使用Spring Boot LayerTools模式时找不到Jarlauncher
我使用layertools
jar 模式提取了我的应用程序构建文件。 (参考https://docs. spring.io/spring-boot/docs/current/reference/htmlsingle/#container-images.dockerfiles)
结果,提取了四个文件,如下所示。
application
dependencies
snapshot-dependencies
spring-boot-loader
然后,在同一目录中,我尝试通过执行以下命令来运行该应用程序:
$java org.springframework.boot.loader.JarLauncher
但是,发生了错误。
java.lang.ClassNotFoundException: org.springframework.boot.loader.JarLauncher
MANIFEST.MF
如下。
Manifest-Version: 1.0
Main-Class: org.springframework.boot.loader.JarLauncher
Start-Class: com.henry.myproject.HelloApplicationKt
Spring-Boot-Version: 2.6.4
Spring-Boot-Classes: BOOT-INF/classes/
Spring-Boot-Lib: BOOT-INF/lib/
Spring-Boot-Classpath-Index: BOOT-INF/classpath.idx
Spring-Boot-Layers-Index: BOOT-INF/layers.idx
为什么会出现此错误?
I extracted my app build file using layertools
jar mode.
(ref. https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#container-images.dockerfiles)
As a result, four files were extracted as follows.
application
dependencies
snapshot-dependencies
spring-boot-loader
Then, in the same directory, I tried to run the application by executing the following command:
$java org.springframework.boot.loader.JarLauncher
However, an error occurred.
java.lang.ClassNotFoundException: org.springframework.boot.loader.JarLauncher
MANIFEST.MF
is as follows.
Manifest-Version: 1.0
Main-Class: org.springframework.boot.loader.JarLauncher
Start-Class: com.henry.myproject.HelloApplicationKt
Spring-Boot-Version: 2.6.4
Spring-Boot-Classes: BOOT-INF/classes/
Spring-Boot-Lib: BOOT-INF/lib/
Spring-Boot-Classpath-Index: BOOT-INF/classpath.idx
Spring-Boot-Layers-Index: BOOT-INF/layers.idx
Why does this error occur?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这四个目录中的每一个都旨在用作 Docker 映像中的单独层。需要将它们复制到一个目录中。在 Dockerfile 中,它看起来像这样:
然后可以从层复制到的目录启动应用程序。
Each of the four directories is intended to be used as a separate layer in a Docker image. They need to be copied into a single directory. In a Dockerfile, that would look like this:
The application can then be launched from the directory into which the layers have been copied.
如果您最近更新到 Spring Boot 3,则必须将包名称从: 更改
为:
If you recently updated to Spring Boot 3, you have to change the package name from:
to: