一、准备工作
本地开发环境如下:
- 操作系统:Windows10
- Java:JDK11
- 集成开发环境:IntelliJ IDEA 2023.2.5 (Community Edition)
- Maven:3.9.2 – 好像使用IDEA自带的Maven也没有问题
kettle:https://gitee.com/mirrors/Kettle
标签选择:9.4.0.1-R 版本,直接下载。或者使用git拉取到本地后,切换标签
– 注意,如果不选用较为稳定的版本。有些依赖可能找不到。因为可能并没有上传到中心仓。
- 我这里选择使用git进行拉取
git clone https://gitee.com/mirrors/Kettle.git
- 进入Kettle目录
cd Kettle/
- 切换tag
git checkout 9.4.0.1-R
- 使用IDEA打开它
等待IDEA将项目加载完毕,然后JDK选择11
二、打包kettle
-
刷新maven,让所有的依赖都拉到本地
-
屏蔽maven的test
-
双击package,等待打包结束
-
最终打包的产物在
assemblies/client/target/pdi-ce-9.4.0.1-467.zip
-
pdi-ce-9.4.0.1-467.zip解压后,找到Spoon.bat,双击,就能运行。
三、运行调试kettle
- 先运行maven的clean。然后,找到Spoon类,这个是kettle客户端的启动类。直接启动
- 此时遇到第一个报错:
java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons:
解决办法:在ui/pom.xml文件中排掉:org.eclipse.swt.gtk.linux.x86_64。并加入:org.eclipse.swt.win32.win32.x86_64
- 第二个错误:
org.pentaho.di.core.exception.KettleException:
Unable to find plugin with ID 'Kettle'. If this is a test, make sure kettle-core tests jar is a dependency. If this is live make sure a kettle-password-encoder-plugins.xml exits in the classpath
解决办法:将core/src/it/resources/kettle-password-encoder-plugins.xml复制到ui/src/main/resources/
- 第三个错误:
java.lang.NoClassDefFoundError: org/apache/xmlgraphics/java2d/color/NamedColorSpace
解决办法:在ui/pom.xml文件中加入xmlgraphics-commons
- 第四个报错:
org.pentaho.ui.xul.XulException: Can not locate Xul document [ui/spoon.xul]
解决办法:将assemblies/static/src/main/resources/ui目录下文件都复制到ui/src/main/resources/ui
- 第五个报错:
java.lang.NoClassDefFoundError: org/jaxen/JaxenException
解决办法:在ui/pom.xml文件中加入jaxen
注意:更改了pom.xml都要重新刷新maven
- 最终成功,可以愉快的调试代码了(_)
三、总结
- kettle本地调试坑很多,一定要看懂报错,才能找到问题的解决方案。
- 遇到不好解决的问题,可以对比打包后的文件结构,与项目编译后文件文件。判断是不是缺失什么文件。