如何在springboot项目中引入本地jar

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档


前言

我在项目中需要实现一个功能,计算word字数,行数等,但是在网上找到的依赖引入不进来,但是找到了该依赖的jar,于是想通过引入jar到maven仓库


一、如何引入本地依赖到maven仓库?

  mvn install:install-file
 -Dfile=D:\software\maven_repo\org\postgresql\hgjdbc\6.0.3-SNAPSHOT\hgjdbc-6.2.0.jar
 -DgroupId=org.postgresql
 -DartifactId=hgjdbc
 -Dversion=6.0.3-SNAPSHOT
 -Dpackaging=jar

类似于上述的mvn引入方式,遗憾的是,我并没有引入成功。同时考虑到本地maven仓库引入成功后,在线上还需要再次引入,所以我放弃了这种方式

二、代码中引入

1.创建lib文件夹

在src同级目录下创建lib文件夹,并且将jar放置这个文件夹下

2.pom引入

        <dependency>
            <groupId>hisw</groupId>
            <artifactId>wordread</artifactId>
            <version>1.0</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/lib/spire.doc.free-3.9.0.jar</systemPath>
        </dependency>

groupId和artifactId和version随便写,scope作用范围是system,systemPath写当前文件路径

打包配置修改,新增configuration

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>2.1.4.RELEASE</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>build-info</goal>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <executable>true</executable>
                    <includeSystemScope>true</includeSystemScope>
                </configuration>
            </plugin>
        </plugins>
    </build>

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值