maven打包插件配置模板

主要有两类:

1、maven-shade-plugin

主要用于java程序编写的的打包

<build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.pluginsgroupId>
        <artifactId>maven-shade-pluginartifactId>
        <version>3.2.4version>
        <executions>
          <execution>
            <phase>packagephase>
            <goals>
              <goal>shadegoal>
            goals>
            <configuration>
              <artifactSet>
                <excludes>
                  <exclude>com.google.code.findbugs:jsr305exclude>
                  <exclude>org.slf4j:*exclude>
                  <exclude>log4j:*exclude>
                  <exclude>org.apache.hadoop:*exclude>
                excludes>
              artifactSet>
              <filters>
                <filter>
                  
                  <artifact>*:*artifact>
                  <excludes>
                    <exclude>META-INF/*.SFexclude>
                    <exclude>META-INF/*.DSAexclude>
                    <exclude>META-INF/*.RSAexclude>
                  excludes>
                filter>
              filters>
              <transformers combine.children="append">
                <transformer
                        implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer">
                transformer>
              transformers>
            configuration>
          execution>
        executions>
      plugin>
    plugins>
  build>

2、maven-assembly-plugin

主要用于scala和java编写的程序的打包插件(更推荐于scala,java有时候会有问题)



org.apache.maven.plugins
maven-assembly-plugin
3.0.0


jar-with-dependencies




make-assembly
package

single





org.apache.maven.plugins
maven-compiler-plugin
3.8.0

j a v a . v e r s i o n < / s o u r c e > < t a r g e t > {java.version} java.version</source><target>{java.version}
UTF-8



你可能感兴趣的:(maven,java)