SpringBoot引用第三方jar

1.将jar添加到SpringBoot项目的resources文件下

pom.xml引用

<!--引入jar包 HtmlDownLoader.jar -->
<dependency>
    <groupId>cn.lg</groupId>
    <artifactId>html-downloader</artifactId>
    <scope>system</scope>
    <version>1.0</version>           
    <systemPath>${project.basedir}/src/main/resources/lib/HtmlDownLoader.jar</systemPath>
</dependency>

如果我们想在打包时将该jar添加进去,需要而外声明

<!--打包时引入SystemScope级别-->
<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <executable>true</executable>
        <includeSystemScope>true</includeSystemScope>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>repackage</goal>
            </goals>
        </execution>
    </executions>
</plugin>

2.将第三方jar修改为maven仓库中jar

wind+R输入cmd指令

mvn install:install-file 
    -Dfile=C:\Users\dell\Documents\work\HtmlDownLoader.jar \ #jar包位置
    -DgroupId=cn.cat.code \    #设置groupId
    -DartifactId=HtmlDownLoader \ #设置artifactId
    -Dversion=1.0 \    #设置自版本号
    -Dpackaging=jar \    #打包类型
    -DgeneratePom=true   #生成配置文件

【注】:artifactId 不能携带"-"等特殊符号,在引用时注意大小写

pom.xml引用

<dependency>
    <groupId>cn.cat.code</groupId>
    <artifactId>htmlDownLoader</artifactId>
    <version>1.0</version>
</dependency>

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值