maven打包,分离jar包和业务包

本文介绍如何在SpringBoot项目中通过Maven插件配置,指定将依赖的jar包保留在启动jar中,并将lib目录中的jar复制到外部,以便于部署。重点强调了排除部分业务模块依赖,确保应用的轻量化。
摘要由CSDN通过智能技术生成
 <build>
            <plugins>
                <!--设置应用 Main 参数启动依赖查找的地址指向外部 lib 文件夹-->
<!--                <plugin>-->
<!--                    <groupId>org.apache.maven.plugins</groupId>-->
<!--                    <artifactId>maven-jar-plugin</artifactId>-->
<!--                    <configuration>-->
<!--                        <archive>-->
<!--                            <manifest>-->
<!--                                <addClasspath>true</addClasspath>-->
<!--                                &lt;!&ndash; 项目所依赖的jar位于同一级的lib目录下&ndash;&gt;-->
<!--                                <classpathPrefix>lib/</classpathPrefix>-->
<!--                            </manifest>-->
<!--                        </archive>-->
<!--                    </configuration>-->
<!--                </plugin>-->
                <!--设置 SpringBoot 打包插件不包含任何 Jar 依赖包-->
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <configuration>
                        <layout>ZIP</layout>
    <!--                    <includes>-->
    <!--                        <include>-->
    <!--                            <groupId>nothing</groupId>-->
    <!--                            <artifactId>nothing</artifactId>-->
    <!--                        </include>-->
    <!--                    </includes>-->
                        <includes>
                            <!-- 项目启动jar包中保留依赖包 -->
                            <include>
                                <groupId>org.jeecgframework.boot</groupId>
                                <artifactId>jeecg-system-local-api</artifactId>
                            </include>
                            <include>
                                <groupId>org.jeecgframework.boot</groupId>
                                <artifactId>jeecg-boot-base-core</artifactId>
                            </include>
                            <include>
                                <groupId>org.jeecgframework.boot</groupId>
                                <artifactId>jeecg-module-admin</artifactId>
                            </include>
                            <include>
                                <groupId>org.jeecgframework.boot</groupId>
                                <artifactId>jeecg-system-api</artifactId>
                            </include>
                            <include>
                                <groupId>org.jeecgframework.boot</groupId>
                                <artifactId>jeecg-system-biz</artifactId>
                            </include>
                            <include>
                                <groupId>org.jeecgframework.boot</groupId>
                                <artifactId>jeecg-boot-common</artifactId>
                            </include>
                        </includes>
                    </configuration>
                </plugin>
                <!--设置将 lib 拷贝到应用 Jar 外面-->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>copy-dependencies</id>
                            <phase>prepare-package</phase>
                            <goals>
                                <goal>copy-dependencies</goal>
                            </goals>
                            <configuration>
                                <outputDirectory>${project.build.directory}/lib</outputDirectory>
                                <overWriteIfNewer>true</overWriteIfNewer>
                                <overWriteReleases>false</overWriteReleases>
                                <overWriteSnapshots>false</overWriteSnapshots>
<!--                                stripVersion 表示复制的jar文件去掉版本信息。(依赖的jar包都不带版本号了,例如:asm.jar,默认:asm-5.0.4.jar)-->
<!--                                <stripVersion>false</stripVersion>-->
                                <!-- 不包含哪些jar包 -->
                                <excludeGroupIds>
                                    <!-- 只排除业务模块相关的jar包,多个用英文逗号分割-->
                                    org.jeecgframework.boot
                                </excludeGroupIds>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值