gpt4 book ai didi

Spring Boot可执行jar结构

转载 作者:行者123 更新时间:2023-12-01 16:35:14 25 4
gpt4 key购买 nike

我正在尝试运行 Spring Boot 示例应用程序。我在 webapp 文件夹下的“images”文件夹中添加了几张图像(与 WEB-INF 同一级别)。

我创建了可执行 jar,这些图像在网页上正确显示。

但是,我很困惑,可执行 jar 中的图像文件夹在哪里?这些图像位于 lib jar 之一中吗?

提前致谢。

更新:在另一台机器上尝试相同的 jar 后,问题完全改变了。现在,我可以确认这些图像不是可执行“fat”jar 的一部分,因为这些图像不会出现在网页上。更进一步,“webapp”下的文件都没有打包到jar中。我已将 spring-boot-maven-plugin 插件放入 pom 中,并使用“mvn package”来创建 jar。在我的src项目中,webapp位于src/main下(与java和resource同级)。

最佳答案

这在 documentation about static resources 中有介绍。 :

Do not use the src/main/webapp folder if your application will be packaged as a jar. Although this folder is a common standard, it will only work with war packaging and it will be silently ignored by most build tools if you generate a jar.

您应该将静态资源放在 src/main/resources 中。

关于Spring Boot可执行jar结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26517324/

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