maven如何在ApacheBeamJavaSDK中使用GCS中的自定义JDBCJAR文件
我有一个用例,即从GCS读取一个文件,并通过Apache Beam将其写入我们自己的数据仓库产品。我们有一个定制的JDBC驱动程序(.jar)来连接仓库,我正在尝试使用ApacheBeam的JdbcIO来执行ETL和maven pom来管理依赖关系。有人能帮助我理解如何在ApacheBeam中利用这个定制jar文件吗
p.apply(JdbcIO.<KV<Integer, String>>read()
.withDataSourceConfiguration(JdbcIO.DataSourceConfiguration.create(
"MYDRIVERCLASS", "DATABASE_URL")
.withUsername("username")
.withPassword("password"))
.withQuery("select id,name from Person")
.withCoder(KvCoder.of(BigEndianIntegerCoder.of(), StringUtf8Coder.of()))
.withRowMapper(new JdbcIO.RowMapper<KV<Integer, String>>() {
public KV<Integer, String> mapRow(ResultSet resultSet) throws Exception {
return KV.of(resultSet.getInt(1), resultSet.getString(2));
}
})
);
# 1 楼答案
可以在代码中使用this example code,以及如何使用它
如本例所示,您可以构建并运行文件。你可以看到更多documentation
# 2 楼答案
要使用其他依赖JAR,只需在运行Beam Java管道时将此类JAR添加到类路径中即可。类路径中的所有JAR都应该由光束跑步者进行分段
还可以使用thisPipelineOption指定依赖项