如何在Maven软件包中包含自定义文件夹?

问题描述 投票:0回答:1

下面是我的项目结构:

META-INF/abc.jpg
META-INF/xyz.jpg
src/com/hcc/files.java
pom.xml

下面是pom.xml的内容:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>xyz</groupId>
    <artifactId>zyx</artifactId>
    <packaging>jar</packaging>
    <version>1.0.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <build>
        <resources>
            <resource>
                <directory>src</directory>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <groupId>org.apache.maven.plugins</groupId>
                <version>3.2.3</version>
                <configuration>
                    <webResources>
                        <resource>
                            <directory>META-INF</directory>
                            <filtering>true</filtering>
                            <targetPath>META-INF</targetPath>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>abc</groupId>
            <artifactId>abc</artifactId>
            <version>936</version>
            <scope>system</scope>
            <systemPath>path</systemPath>
        </dependency>
    </dependencies>
</project>

[当我尝试使用mvn compile进行编译时,它将创建一个目标文件夹。

ex - target/classes/com/hcc

[在创建包(即mvn包)时如何原样包含META-INF文件夹,以便我的jar文件原样包含目标文件夹文件和META-INF文件夹。

java maven jar maven-3 maven-plugin
1个回答
0
投票

pom.xml的build部分中,您可以在maven war插件声明下添加必要的配置,在其中您将Web资源指定为目录,并且它也是输出路径:

© www.soinside.com 2019 - 2024. All rights reserved.