使用Spring Boot LayerTools模式时找不到Jarlauncher

发布于 2025-01-16 17:20:41 字数 1067 浏览 3 评论 0原文

我使用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

若能看破又如何 2025-01-23 17:20:41

这四个目录中的每一个都旨在用作 Docker 映像中的单独层。需要将它们复制到一个目录中。在 Dockerfile 中,它看起来像这样:

COPY --from=builder application/dependencies/ ./
COPY --from=builder application/spring-boot-loader/ ./
COPY --from=builder application/snapshot-dependencies/ ./
COPY --from=builder application/application/ ./

然后可以从层复制到的目录启动应用程序。

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:

COPY --from=builder application/dependencies/ ./
COPY --from=builder application/spring-boot-loader/ ./
COPY --from=builder application/snapshot-dependencies/ ./
COPY --from=builder application/application/ ./

The application can then be launched from the directory into which the layers have been copied.

药祭#氼 2025-01-23 17:20:41

如果您最近更新到 Spring Boot 3,则必须将包名称从: 更改

org.springframework.boot.loader.JarLauncher

为:

org.springframework.boot.loader.launch.JarLauncher

If you recently updated to Spring Boot 3, you have to change the package name from:

org.springframework.boot.loader.JarLauncher

to:

org.springframework.boot.loader.launch.JarLauncher

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文