0%

Flink:HBaseConnectors

Flink HBase connectors

flighting

奇怪,没有依赖HBase-Client,而是依赖了HBase-server

1
2
3
4
5
6
7
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-hadoop2-compat</artifactId>
<version>${hbase.version}</version>
<scope>test</scope>
<type>test-jar</type>
</dependency>
1
2
3
4
5
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-server</artifactId>
<version>${hbase.version}</version>
</dependency>

添加文件到ClassLoader的classpath

1
2
3
4
5
6
7
8
9
10
11
12
// Get the classloader actually used by HBaseConfiguration
ClassLoader classLoader = HBaseConfiguration.create().getClassLoader();
if (!(classLoader instanceof URLClassLoader)) {
fail("We should get a URLClassLoader");
}

// Make the addURL method accessible
Method method = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
method.setAccessible(true);

// Add the directory where we put the hbase-site.xml to the classpath
method.invoke(classLoader, directory.toURI().toURL());