Maven项目手动引入Jar包,进行编译、打包

前言: 有时我们项目中用到了三方的Jar包,在Maven中心仓库中没有。那这时候我们就要手动把Jar包下载好,然后导入到项目中使用;当然也可以把Jar包上传到自己公司的私服中(本文不考虑此种情况)。

环境

  • Maven项目

步骤

1、上传Jar包:在使用Jar包的项目模块下创建lib文件夹,并且把Jar放入;如图

2、配置pom文件: 在当前模块下的pom.xml中添加如下配置:如图:

         2-1、添加Jar坐标:

        <dependency>
            <groupId>com.aspose</groupId>
            <artifactId>aspose-words</artifactId>
            <version>14.7.0</version>
            <scope>system</scope>
            <!-- ${pom.basedir}:此pom.xml文件所在的项目模块路径 -->
            <systemPath>${pom.basedir}/lib/aspose-words-15.8.0-jdk16.jar</systemPath>
        </dependency>

        2-2、添加编译和打包的plugin:

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>UTF-8</encoding>
                    <compilerArguments>
                        <extdirs>${project.basedir}/lib</extdirs>
                    </compilerArguments>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <includeSystemScope>true</includeSystemScope>
                </configuration>
            </plugin>

测试:

编译:mvn compile

打包:mvn package (该Jar包打进了项目.jar的\BOOT-INF\lib目录中);


注意: 项目使用Jenkins打包/部署的也是一样,只要自己本地可以正常编译/打包。

  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值