转自:https://blog.csdn.net/li_wei_ying0809/article/details/83619411
maven+kettle调用ktr文件,与web项目集成demo: https://blog.csdn.net/hncu1306602liuqiang/article/details/82804438
kettle的maven依赖没有找到,通过自己向maven库中添加,解决了springboot web项目调用kettle的问题
解决方法如下:
1.向maven中添加jar
需要添加的jar包包括:kettle-core.jar,
kettle-engine.jar,metastore.jar,vfs2.jar, scannotation.jar
这些包在kettle的解压路径 pdi-ce-7.0.0.0-25\data-integration\lib 下可以找到
添加方法如下:
mvn install:install-file -Dfile=C:\ml\pdi-ce-7.0.0.0-25\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=C:\ml\pdi-ce-7.0.0.0-25\data-integration\lib\kettle-core-7.0.0.0-25.jar -DgroupId=pentaho-kettle -DartifactId=kettle-core -Dversion=7.0.0.0-25 -Dpackaging=jar
mvn install:install-file -Dfile=C:\ml\pdi-ce-7.0.0.0-25\data-integration\lib\kettle-engine-7.0.0.0-25.jar -DgroupId=pentaho-kettle -DartifactId=kettle-engine -Dversion=7.0.0.0-25 -Dpackaging=jar
mvn install:install-file -Dfile=C:\ml\pdi-ce-7.0.0.0-25\data-integration\lib\metastore-7.0.0.0-25.jar -DgroupId=pentaho-kettle -DartifactId=metastore -Dversion=7.0.0.0-25 -Dpackaging=jar
mvn install:install-file -Dfile=C:\ml\pdi-ce-7.0.0.0-25\data-integration\lib\scannotation-1.0.2.jar -DgroupId=pentaho-kettle -DartifactId=scannotation -Dversion=1.0.2 -Dpackaging=jar
C:\ml\pdi-ce-7.0.0.0-25\是我的kettle解压路径,这个命令可以通过cmd窗口执行
mvn命令需要添加环境变量,如果不添加,需要进入maven的bin目录执行
2. 在工程pom.xml中添加依赖
<dependency>
<groupId>pentaho-kettle</groupId>
<artifactId>kettle-core</artifactId>
<version>7.0.0.0-25</version>
</dependency>
<dependency>
<groupId>pentaho-kettle</groupId>
<artifactId>kettle-engine</artifactId>
<version>7.0.0.0-25</version>
</dependency>
<dependency>
<groupId>pentaho-kettle</groupId>
<artifactId>vfs2</artifactId>
<version>2.1-20150824</version>
</dependency>
<dependency>
<groupId>pentaho-kettle</groupId>
<artifactId>metastore</artifactId>
<version>7.0.0.0-25</version>
</dependency>
<dependency>
<groupId>pentaho-kettle</groupId>
<artifactId>scannotation</artifactId>
<version>1.0.2</version>
</dependency>
3.依然报错
在工程中 添加如下测试代码
KettleEnvironment.init();
TransMeta tm = new TransMeta(filename);
Trans trans = new Trans(tm);
// 空参调用
trans.execute(null);
trans.waitUntilFinished();
在执行到KettleEnvironment.init()时, 依然报java.lang.NoClassDefFoundError: javassist/bytecode/ClassFile错误
4.终于可以成功执行了
再添加
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.20.0-GA</version>
</dependency>
这个依赖后,终于可以正常执行了
---------------------
作者:li_wei_ying0809
来源:CSDN
原文:https://blog.csdn.net/li_wei_ying0809/article/details/83619411
版权声明:本文为博主原创文章,转载请附上博文链接!