为了编译能通过,maven需要加入仓库地址以及一些必须要的包的依赖情况:

  1. pentaho中央仓库:

在properties里面配置版本号:

<kettle.version>6.0.0.0-353</kettle.version>

<repository>

<id>pentaho1</id>

<name>Pentaho Repository1</name>

<url>http://repository.pentaho.org/artifactory/repo/</url>

<snapshots>

<enabled>true</enabled>

</snapshots>

</repository>

2.kettle一些核心的依赖,由于有些jar包下载不下来,所以exclution掉之后再去mvn仓库找合适的包:

<!-- kettle begin -->

<dependency>

<groupId>pentaho-kettle</groupId>

<artifactId>kettle-core</artifactId>

<version>${kettle.version}</version>

<exclusions>

<exclusion>

<groupId>jug-lgpl</groupId>

<artifactId>jug-lgpl</artifactId>

</exclusion>

<exclusion>

<groupId>org.apache.commons</groupId>

<artifactId>commons-vfs2</artifactId>

</exclusion>

<exclusion>

<groupId>secondstring</groupId>

<artifactId>secondstring</artifactId>

</exclusion>

<exclusion>

<groupId>org.slf4j</groupId>

<artifactId>slf4j-log4j12</artifactId>

</exclusion>

<exclusion>

<artifactId>xercesImpl</artifactId>

<groupId>xerces</groupId>

</exclusion>

<exclusion>

<groupId>org.apache.xmlgraphics</groupId>

<artifactId>batik-js</artifactId>

</exclusion>

</exclusions>

</dependency>

<dependency>

<groupId>pentaho-kettle</groupId>

<artifactId>kettle-engine</artifactId>

<version>${kettle.version}</version>

<exclusions>

<exclusion>

<groupId>org.apache.commons</groupId>

<artifactId>commons-vfs2</artifactId>

</exclusion>

</exclusions>

</dependency>

<dependency>

<groupId>pentaho-library</groupId>

<artifactId>libbase</artifactId>

<version>${kettle.version}</version>

</dependency>

<dependency>

<groupId>pentaho-library</groupId>

<artifactId>libformula</artifactId>

<version>${kettle.version}</version>

</dependency>

<dependency>

<groupId>pentaho</groupId>

<artifactId>metastore</artifactId>

<version>${kettle.version}</version>

</dependency>

<dependency>

<groupId>pentaho</groupId>

<artifactId>pentaho-mongodb-plugin</artifactId>

<version>${kettle.version}</version>

</dependency>

<dependency>

<groupId>pentaho</groupId>

<artifactId>pentaho-mongo-utils</artifactId>

<version>6.0.0.0-351</version>

</dependency>

<dependency>

<groupId>org.apache.commons</groupId>

<artifactId>commons-vfs2</artifactId>

<version>2.1</version>

</dependency>

<dependency>

<groupId>net.sourceforge.jexcelapi</groupId>

<artifactId>jxl</artifactId>

<version>2.6.12</version>

</dependency>

<dependency>

<groupId>rhino</groupId>

<artifactId>js</artifactId>

<version>1.7R2</version>

</dependency>

<!-- kettle end -->

3.下载jar包时当遇到500m大小的jar时,暂停mvn手动下载然后移动到本地仓库

插件的路径:D:\dev\apache-maven-3.3.9\repository\pentaho\pentaho-big-data-plugin\6.0.0.0-353

4.java调本地ktr代码:

 import java.util.List;

 import org.junit.Test;
import org.junit.runner.RunWith;
import org.pentaho.di.core.KettleEnvironment;
import org.pentaho.di.core.Result;
import org.pentaho.di.core.RowMetaAndData;
import org.pentaho.di.core.exception.KettleException;
import org.pentaho.di.job.Job;
import org.pentaho.di.job.JobMeta;
import org.pentaho.di.trans.Trans;
import org.pentaho.di.trans.TransMeta;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import cn.shunlu.repository.BaseDataInitTest; @RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations="/applicationContext.xml")
public class KettleTest extends BaseDataInitTest{ private static Logger logger = LoggerFactory.getLogger(KettleTest.class); private static final String KETTLE_PLUGIN_BASE_FOLDER = "E:\\dev\\pentaho\\data-integration\\plugins\\";
// private static final String KETTLE_PLUGIN_BASE_FOLDER = "C:\\dev\\pentaho6\\data-integration\\system\\karaf\\system\\pentaho";
// private static final String KETTLE_PLUGIN_BASE_FOLDER = "C:\\dev\\pentaho6\\data-integration\\plugins"; /**
* 调转换
*/
@Test
public void test() {
logger.info("hi"+ logger.getClass().getName());
try
{
//这里是设置我们pentaho的运行环境,实际上我们加入的maven依赖只是为了让代码编译通过,实际真正干活的还是pentaho自己
//也可以自己建个maven的私服把pentaho里面的运行环境的jar丢上去,就能通过java调了
System.setProperty("KETTLE_PLUGIN_BASE_FOLDERS", KETTLE_PLUGIN_BASE_FOLDER);
String transPath = "e:\\tmp\\2.ktr"; KettleEnvironment.init(); TransMeta transMeta = new TransMeta(transPath); Trans trans = new Trans(transMeta);
System.out.println(trans);
trans.setVariable("importOrExport", "出口");
trans.setVariable("batchId", "57bebcfd816c0dffb72d6fa4");
trans.setVariable("codeMap_type", "country");
trans.execute(null); trans.waitUntilFinished(); Result r = trans.getResult();
List<RowMetaAndData> rowsResult = r.getRows(); if (trans.getErrors() > 0)
{
throw new Exception(trans.getResult().getLogText());
}
}
catch (Exception e)
{
e.printStackTrace();
}
} /**
*
* @description 调job
* @date 2016年9月6日
* @author
*/
@Test
public void testJob() throws Exception{
logger.info("hi"+ logger.getClass().getName());
try {
System.setProperty("KETTLE_PLUGIN_BASE_FOLDERS", KETTLE_PLUGIN_BASE_FOLDER); String jobPath = "e:\\tmp\\job1.kjb";
KettleEnvironment.init(); JobMeta jobMeta = new JobMeta(jobPath, null); Job job = new Job(null, jobMeta); job.setVariable("importOrExport", "出口");
job.setVariable("batchId", "57bebcfd816c0dffb72d6fa4");
job.setVariable("codeMap_type", "country"); job.start();
job.waitUntilFinished(); if (job.getErrors() > 0) {
throw new Exception(
"There are errors during job exception!(执行job发生异常)");
}
} catch (KettleException e) {
e.printStackTrace();
}
} }

注:加依赖的目的就是为了让编译能通过,最后运行的环境其实还是我们手动指定的plugins目录如图所示:

这里只是写了个testCase来调用我们本地.ktr和.kjb pentaho这边接收参数的话,我也是只做了个简单的job.

调转换就直接这么接收参数:

如果是调job接收命名参数需要在他的下一个步骤转换里面设置写命名参数就行了:

然后这个转换还是跟上一个转换一样的,而且参数也是那么接收的.${paramName}这样子.其实代码网上很多,但是整合maven那些依赖之间的关系特麻烦.

最近整合发现个问题,如果不将mongo-plugins和mongo-utils包放入plugins目录里面也无法成功调用,因此需要去到,

增加完之后的plugins目录:

Javaweb整合mongo和kettle6.0的环境配置的更多相关文章

  1. cocos2d-x3.0 windows 环境配置

    cocos2d-x3.0 windows 环境配置 参考Oo泡泡糖oO的CSDN博文 :http://blog.csdn.net/u010296979/article/details/24273393 ...

  2. springboot学习入门简易版八---springboot2.0多环境配置、整合mybatis mysql8+(19-20)

    2.11 SpringBoot多环境配置(19)  application.properties中配置 Spring.profiles.active=prd 配置环境: Application-dev ...

  3. 【MRPT】【icp-slam-live】Vs2013+ cmake3.6.1 + mrpt1.4.0+opencv2.9.4+wxWidget3.0.2环境配置

    Win10下Vs2013 + cmake3.6.1 + mrpt1.4.0+opencv2.9.4+wxWidget3.1.0环境配置 所接触过的最令我崩溃的环境配置.之前没有考虑到vs2013 20 ...

  4. Berkeley DB (VC6.0 编译环境配置)

    操作系统:winxp VC环境:VC6.0 必需文件:Berkeley DB安装文件(db-.msi) 下载地址:http://www.oracle.com/technology/software/p ...

  5. 75.VS2013和opencv3.1.0开发环境配置

    首先要做的就是 开发环境配置,具体过程如下: Step 1:OpenCV环境变量配置 我的电脑--->属性--->高级系统设置--->高级--->环境变量--->系统变量 ...

  6. activiti自定义流程之整合(一):整体环境配置

    结合之前所说的自定义流程的思路,分别是后台.前台.整合,之前的内容也分别进行了相关的练习和尝试,现在就该到了最后的整合了,依旧是以实现功能为目的,细节暂且不去管他. 因为我们实际项目后端用的是spri ...

  7. mac在xampp下使用yii2.0开发环境配置

    在mac上装环境,折腾了我好久.先用是mac自带的php,但自带的PHP很多扩展都需要自己安装.libevent,memcache等扩展都安装好了之后,发现pdo_mysql.dll扩展又没有,悲剧的 ...

  8. Win7 OpenCV 3.0.0 VS2013 环境配置

    参考资料:http://jingyan.baidu.com/article/75ab0bcbee4b47d6864db2fc.html 注: x86 x64 这些根据自己的系统以及需求而定, 这里就不 ...

  9. gtk+3.0的环境配置及基于gtk+3.0的python简单样例

    /*********************************************************************  * Author  : Samson  * Date   ...

随机推荐

  1. Codeforces Round #245 (Div. 1)——Working out

    题目链接 题意: 一个n*m的矩阵,每一个方格有一个非负数,如今选择两条线路:一个左上到右下,一个左下到右上,且仅仅能有一个公共点. 求两个线路上数的最大值(公共点不算) 分析: 仅仅有两种情况,dp ...

  2. oracle优化思考-双刃剑

    oracle优化是一个双刃剑,特别注意这把剑用的场合:系统规划OLTP or OLAP 优化1:索引 在DML操作时.必须维护索引.假设大量的DML操作,想想看,IO是不是老高了? 索引长处:在非常多 ...

  3. To restore the database on a new host-将数据库恢复至一个新的主机上

    To restore the database on a new host:1. Ensure that the backups of the target database are accessib ...

  4. golang之interface

    一.概述 接口类型是对 "其他类型行为" 的抽象和概况:因为接口类型不会和特定的实现细节绑定在一起:很多面向对象都有类似接口概念,但Golang语言中interface的独特之处在 ...

  5. pixel像素与物理像素

  6. Linux修改Shell命令提示符及颜色

    Linux修改Shell命令提示符及颜色 1. Linux登录过程中加载配置文件顺序: /etc/profile → /etc/profile.d/*.sh → ~/.bash_profile → ~ ...

  7. php的SQL连接操作的方法

    初学php,于是一开始就在sql(具体点说是mysql)里受挫严重.于是这里记下一些方法. 首先是基本方法.基本方法现在我不用了,所以我就附一下hustoj中的部分吧 基本方法的数据库连接操作: if ...

  8. Inno Setup打包的程序提升为管理员权限

    Inno Setup打包的程序在Win7 64位系统上安装,安装步骤最后一步若选中运行程序,会跳出一个错误提示框. 这是因为64位win7系统运行程序时需要管理员权限,而打包的文件并没有这个权限就试图 ...

  9. sfs

    http://tieba.baidu.com/p/3397811202 http://mooc.guokr.com/post/610664/ http://home.ustc.edu.cn/~boj/ ...

  10. Server2008系统 FTP下载“当前的安全设置不允许”的解决方法

    IE -> Internet选项 -> 安全 -> Internte -> 自定义级别 设置 -> 下载 -> 文件下载 -> 启动