【发布时间】:2020-06-13 14:08:48
【问题描述】:
我的项目在 src/main/resources 和使用 mvn spring-boot:repackage 下有一个空文件夹 'static' 'static' 文件夹尚未复制到 'target' 文件夹,但只要 'static' 文件夹包含任何文件,如 'src/main /resources/static/images/asb.jpg' 然后将文件及其父目录复制到'target'。我浏览了 spring-boot-maven-plugin 文档,但没有找到任何解决方案。
我注意到 maven-build-plugin 有如下配置,可以将空文件夹复制到 target。但没有找到 spring-boot-maven-plugin 的任何解决方案。
<configuration>
<includeEmptyDirectories>true</includeEmptyDirectories>
</configuration>
【问题讨论】:
-
你试过添加这个插件配置
<configuration> <addResources>true</addResources> </configuration>吗? -
@lainatnavi 是的,我做到了,但是没有用。
-
问题是为什么要添加一个空目录?
-
@khmarbaise 静态文件夹不一定为空,但有时可能为空。我只想知道在不存在静态内容时如何处理这种情况。
-
@khmarbaise 当您将 .war 文件复制到 tomcat webapps 文件夹时,tomcat 将提取它并运行应用程序。我曾在多个 Web 应用程序上工作过,我什至将用户上传的图像存储到 /static/images/user-directory/image-name.image-extension 并且我从来没有遇到任何问题。在那些 web 应用程序中,war 文件 /static/images 文件夹包含 web 应用程序徽标和其他图像,但在当前的 webapp 中,我在 /static/images 中没有任何图像,所以如果有人知道如何包含空文件夹,那么它会对我有帮助。
标签: java spring-boot maven spring-mvc spring-boot-maven-plugin