maven打包插件配置模板

主要有两类:

1、maven-shade-plugin

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

xml 复制代码
<build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>3.2.4</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <artifactSet>
                <excludes>
                  <exclude>com.google.code.findbugs:jsr305</exclude>
                  <exclude>org.slf4j:*</exclude>
                  <exclude>log4j:*</exclude>
                  <exclude>org.apache.hadoop:*</exclude>
                </excludes>
              </artifactSet>
              <filters>
                <filter>
                  <!-- Do not copy the signatures in the META-INF folder.
                  Otherwise, this might cause SecurityExceptions when using the JAR. -->
                  <artifact>*:*</artifact>
                  <excludes>
                    <exclude>META-INF/*.SF</exclude>
                    <exclude>META-INF/*.DSA</exclude>
                    <exclude>META-INF/*.RSA</exclude>
                  </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}</source> <target> java.version</source><target>{java.version}

UTF-8

相关推荐
渣哥9 分钟前
面试官:为什么阿里巴巴要重写HashMap?ConcurrentHashMap哪里不够用?
java
喵手11 分钟前
Java中的HashMap:你了解它的工作原理和最佳实践吗?
java·后端·java ee
weixin_4565881515 分钟前
【java面试day16】mysql-覆盖索引
java·mysql·面试
心月狐的流火号18 分钟前
计算机I/O模式演进与 Java NIO 直接内存
java·操作系统
猿究院-赵晨鹤21 分钟前
JVM基础知识总结
java·jvm
代码输入中...29 分钟前
JVM常见面试题及答案
java·jvm·java面试·java面试题·jvm面试题
猿究院--冯磊37 分钟前
JVM垃圾收集器
java·jvm·算法
天天摸鱼的java工程师42 分钟前
Go 语言未来会取代 Java 吗?
java·后端
掉鱼的猫1 小时前
Solon AI & MCP v3.5.0 发布(智能体应用开发框架)
java·mcp