java - Maven - 在 war 文件的根部包含外部资源

标签 java spring-boot maven maven-assembly-plugin maven-shade-plugin

我的 Maven 项目的根目录下有一个资源文件。目录结构如下。

src/
pom.xml
resource_file

在 pom.xml 中,我提到的资源为:

<build>
   <resources>
        <resource>
            <directory>.</directory>
            <includes>
                <include>resource_file</include>
            </includes>
        </resource>
    </resources>
</build>

在 war 文件中,resource_file 位于 WEB-INF/classes/resource_file 中。我需要将 resource_file 放置在 war 文件的根目录中。我可以解压缩 war 文件并将 resource_file 移动到 root 并再次创建 war 文件。但是,有没有办法通过maven本身来完成这个任务呢?

最佳答案

默认是将资源放入src/main/webapp目录中,该目录将自动放入生成的war文件的根目录中。

docs还有一个例子。

关于java - Maven - 在 war 文件的根部包含外部资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60092259/

相关文章:

java - 该函数被评估了多少次?

spring-boot - 在 spring-boot 应用程序中使用 Micrometer 和 OpenFeign

spring-mvc - 在 Spring Boot 中使用 StandardPasswordEncoder

eclipse - 在eclipse中查找该类来自哪个库

java - 如何解决maven多模块依赖问题?安装后不是从本地 m2 导入

java/Swing : drag and drop with a list of strings

java - 这两者之间哪个更好?

java - 具有 Spring Boot Oaut2UserService 问题的 Azure Active Directory

java - 为什么系统每次在新的工作空间中都会从 Maven 下载 Google App Engine Java SDK?

java - AccessibilityService 对 OnKeyEvent() 没有响应