maven项目打包(war) 如何排除META-INF中的maven目录?
用chatgpt问了不下十次 给了各种插件的方案 不知道为啥就是不生效
下面是我的pom.xml中的部分片断
<build>
<finalName>bam-console</finalName>
<plugins>
<!-- Run the JUnit unit tests in an isolated classloader -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
<!-- 打包依赖包 -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
<mainClass>com.bamboocloud.am.Application</mainClass>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.*</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>view</directory>
<includes>
<include>**/*.*</include>
</includes>
<filtering>false</filtering>
<targetPath>${basedir}/target/bam-console/view</targetPath>
</resource>
<resource>
<directory>src/main/webapp/META-INF</directory>
<filtering>true</filtering>
<excludes>
<exclude>maven/**</exclude>
</excludes>
</resource>
</resources>
</build>
回答:
pom.xml 中加入如下插件即可
<plugin> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
</archive>
</configuration>
</plugin>
以上是 maven项目打包(war) 如何排除META-INF中的maven目录? 的全部内容, 来源链接: utcz.com/p/945247.html