maven项目引入外部jar

当我们开发一个功能时发现自己的maven仓库中缺少需要的jar怎么办?

  • 首先将需要的jar下载下来
  • 然后将jar导入到项目中:webapp/WEB-INF/lib目录下
  • 最后在pom.xml文件中加入依赖就可以编译和打包运行了
    1
    2
    3
    4
    5
    6
    7
    <dependency>
    <groupId>fakepath</groupId>
    <artifactId>jxl-report</artifactId>
    <version>1.0</version>
    <scope>system</scope>
    <systemPath>${basedir}/src/main/webapp/WEB-INF/lib/jxl-report-1.0.jar</systemPath>
    </dependency>

systemPath:导入外部jar的路径
${basedir}:项目根目录
最终路径为:${basedir}/src/main/webapp/WEB-INF/lib/xxx.jar

本文结束啦感谢您的阅读

本文标题:maven项目引入外部jar

文章作者:Smartfoot

原始链接:http://blog.bestsmartfoot.top/2018/07/12/article-5/

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。

公众号