Maven阴影插件取代了persistence.xml

时间:2018-05-03 08:14:35

标签: java maven maven-plugin maven-shade-plugin

在maven包中我有一种奇怪的行为。我有一件神器" A"这取决于" B"。

在" A"我有一个包含persistence.xml的文件夹META-INF,也在" B"我有一个带有persistence.xml的META-INF文件夹。

这是P的相对于阴影插件和依赖项的文件

    <dependency>
        <groupId>com.mycopany</groupId>
        <artifactId>B</artifactId>
        <version>1.0.2</version>
       </dependency>
   </dependencies>


        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>2.4.2</version>
            <configuration>
                <filters>
                    <filter>
                        <artifact>*:*</artifact>
                        <excludes>
                            <exclude>META-INF/*.SF</exclude>
                            <exclude>META-INF/*.DSA</exclude>
                            <exclude>META-INF/*.RSA</exclude>
                        </excludes>
                    </filter>
                </filters>
                <shadedArtifactAttached>true</shadedArtifactAttached>
            </configuration>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

我如何从&#34; B&#34;中排除persistence.xml文件,考虑到&#34; B&#34;也是阴影神器?

1 个答案:

答案 0 :(得分:1)

使用第二个过滤并排除 persistence.xml ,如下所示:

                <filter>
                    <artifact>B</artifact>
                    <excludes>
                        <exclude>path/persistence.xml</exclude>  
                    </excludes>
                </filter>

更多细节在此question 并在official documentation