【问题标题】:Maven - How to create a POM that place files in the rootMaven - 如何创建一个将文件放在根目录中的 POM
【发布时间】:2021-05-08 01:40:17
【问题描述】:

我需要创建一个 pom.xml 文件来构建一个 jar,并将某些文件放在其根目录上。我现在拥有的 pom.xml 创建了 3 个目录 BOOT-INF、META-INF 和 org。下面是构建部分。我希望文件与目录(BOOT-INF、META-INF、org)处于同一级别。

sparc-jar.jpg

<plugins>

                    <plugin>
                        <groupId>oerg.apache.maven.plugins</groupId>
                        <artifactId>maven-resources-plugin</artifactId>
                        <version>3.1.0</version>
                    </plugin>

                    <plugin>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>build-info</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>

    </plugins>

    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <includes>
                <include>**/*.sh</include>
                <include>**/*.id</include>
                <include>**/*.yaml</include>
                <include>**/*.json</include>
                <include>**/*.properties</include>
                <include>**/*.xml</include>
                <include>**/*.jar</include>
                <include>**/*.js</include>
                <include>**/*.map</include>
                <include>**/*.html</include>
                <include>**/*.hbs</include>
                <include>**/*.cer</include>
                <include>**/*.p12</include>
            </includes>
        </resource>

        <resource>
            <directory>.</directory>
            <includes>
                <include>**/*.yaml</include>
                <include>**/*.json</include>
                <include>**/*.properties</include>
                <include>**/*.xml</include>
                <include>**/*.cer</include>
                <include>**/*.p12</include>
            </includes>
        </resource>
    </resources>
</build>

【问题讨论】:

  • 把你需要的所有信息放到src/main/resources目录中并删除所有配置,因为它不需要。

标签: maven build jar pom.xml


【解决方案1】:

这对我有用...配置 spring-boot-maven-plugin 如下:

<configuration>
   <outputDirectory>${project.basedir}</outputDirectory>
</configuration>

【讨论】:

  • 感谢 nardos 的提示。但是我仍然需要 jar 上的 BOOT-INF 和 META-INF 文件夹。您的配置已删除它们。
猜你喜欢
  • 2016-06-06
  • 2017-04-27
  • 1970-01-01
  • 2014-04-22
  • 2011-05-09
  • 1970-01-01
  • 1970-01-01
  • 2021-04-21
  • 1970-01-01
相关资源
最近更新 更多