ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

springboot通过maven打包时包含本地依赖jar包解决方法

2021-07-08 13:01:13  阅读:298  来源: 互联网

标签:springboot lib 0.0 kettle jar maven pentaho install


最近在用springboot集成kettle做数据传输,kettle依赖的jar包在阿里云仓库没有,因此从kettle文件夹下面找到了相关包,放在项目resources/lib目录下,想通过本地引用的方式依赖。目录如下图
在这里插入图片描述
引用方式则需要在pom中进行配置,其中project.basedir是一个常量,标识和pom同级目录,这个使用就好了不用设置。

 <dependency>
            <groupId>pentaho-kettle</groupId>
            <artifactId>kettle-core</artifactId>
            <scope>system</scope>
            <version>0.0.1</version>
            <systemPath>${project.basedir}/src/main/resources/lib/kettle-core-7.1.0.0-12.jar</systemPath>
        </dependency>
        <dependency>
            <groupId>pentaho-kettle</groupId>
            <artifactId>kettle-engine</artifactId>
            <scope>system</scope>
            <version>0.0.1</version>
            <systemPath>${project.basedir}/src/main/resources/lib/kettle-engine-7.1.0.0-12.jar</systemPath>
        </dependency>
        <dependency>
            <groupId>pentaho-kettle</groupId>
            <artifactId>vfs2</artifactId>
            <scope>system</scope>
            <version>0.0.1</version>
            <systemPath>${project.basedir}/src/main/resources/lib/commons-vfs2-2.1-20150824.jar</systemPath>
        </dependency>
        <dependency>
            <groupId>pentaho-kettle</groupId>
            <artifactId>metastore</artifactId>
            <scope>system</scope>
            <version>0.0.1</version>
            <systemPath>${project.basedir}/src/main/resources/lib/metastore-7.1.0.0-12.jar</systemPath>
        </dependency>
        <dependency>
            <groupId>pentaho-kettle</groupId>
            <artifactId>scannotation</artifactId>
            <scope>system</scope>
            <version>0.0.1</version>
            <systemPath>${project.basedir}/src/main/resources/lib/scannotation-1.0.2.jar</systemPath>
        </dependency>

到这一步,项目中已经可以正常使用这些依赖了,当然还有一个解决办法,就是将这些包上传到私有的maven仓库,然后正常依赖下载也可以,可以通过如下命令进行上传,需要改变以下路径。

mvn install:install-file -Dfile=/Users/scott/middleware/data-integration/lib/commons-vfs2-2.1-20150824.jar -DgroupId=pentaho-kettle -DartifactId=vfs2 -Dversion=2.1-20150824 -Dpackaging=jar

mvn install:install-file -Dfile=/Users/scott/middleware/data-integration/lib/kettle-core-7.1.0.0-12.jar -DgroupId=pentaho-kettle -DartifactId=kettle-core -Dversion=7.1.0.0-12 -Dpackaging=jar

mvn install:install-file -Dfile=/Users/scott/middleware/data-integration/lib/kettle-engine-7.1.0.0-12.jar -DgroupId=pentaho-kettle -DartifactId=kettle-engine -Dversion=7.1.0.0-12 -Dpackaging=jar

mvn install:install-file -Dfile=/Users/scott/middleware/data-integration/lib/metastore-7.1.0.0-12.jar -DgroupId=pentaho-kettle -DartifactId=metastore -Dversion=7.1.0.0-12 -Dpackaging=jar

mvn install:install-file -Dfile=/Users/scott/middleware/data-integration/lib/scannotation-1.0.2.jar -DgroupId=pentaho-kettle -DartifactId=scannotation -Dversion=1.0.2 -Dpackaging=jar

由于我们没有私有仓库,所以还是得使用本地依赖的方式所以使用了第一种方式。但是当项目启动时,发现无法找到依赖的类,报错classnotfound,于是我解压了通过maven编译的jar包,发现这些本地依赖包没有在其中。这个时候我们需要在maven编译的插件中增加一个配置,如下:
在这里插入图片描述

<includeSystemScope>true</includeSystemScope>

这里解释一下,加入该配置,maven在打包时才会引入外部jar包,比如咱们在resouces/lib目录下面的jar包。
这个时候再进行编译打包。进入target目录,我是macos系统使用tar -xvf 进行解压
此时我们进入/target/BOOT-INF/lib 目录下进行搜索
在这里插入图片描述
通过搜索结果可以发现,外部依赖包已经全部编译至我们打的jar包中,并且jar包能完美启动。
看完有用点个关注,谢谢。

标签:springboot,lib,0.0,kettle,jar,maven,pentaho,install
来源: https://blog.csdn.net/u010786653/article/details/118570995

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有