Maven packages jar files and excludes some class files

pom.xml configuration:

<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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.yingjian.test</groupId>
  <artifactId>1.0</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>TestMaven</name>
  <build>
   <resources>
      <resource>
        <directory>src/main/java</directory>
        <excludes>
          <exclude>com/test/aboutjar/*</exclude>                        <!-- Exclude some java files that do not need to be packaged, here is to exclude all java files under the aboutjar package -->         </excludes>
          <exclude>com/test2/aboutjar/Test4.java</exclude>

      </resource>
      <resource>
        <directory>src/main/resources</directory>
        <excludes>
          <exclude>urlrewrite2.xml</exclude>
        </excludes>
      </resource>
    </resources>
    <plugins>
    <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-jar-plugin</artifactId> 
     <configuration> 
       <excludes> 
         <exclude>com/test/aboutjar/*</exclude> <!-- Exclude some class files that do not need to be packaged, here is to exclude all class files under the aboutjar package -->
         <exclude>com/test2/aboutjar/Test4.class</exclude>
       </excludes> 
     </configuration> 
   </plugin> 
   </plugins>
  </build>
</project>

Guess you like

Origin blog.csdn.net/u012411159/article/details/42238085