How can I use hbase with Spring Boot using Java instead of XML?
I have Spring Boot Hadoop and want to take advantage of Spring HbaseTemplate. My problem is that the documentation only contains information about how to “xml” the configuration and settings.
How and where do I define my config as an hbase config in java instead of XML as shown in the official documentation?
http://docs.spring.io/spring-hadoop/docs/1.0.1.RC1/reference/html/hbase.html
Solution
Well, that’s not really an expected answer, but I’d like to overdo it for comment.
I read Spring for Apache Hadoop – Reference Documentation in its latest release, and if it does contain examples and details of namespace configuration, I can’t find a single line about Java configuration.
My understanding of this is that Spring for Apache Hadoop currently only supports namespace configuration. It’s certainly possible to look at classes that support namespaces and hack the working configuration to find out how to get the same result using java configuration, but honestly I don’t think the cost/yield ratio justifies it. Since it is not currently recorded, you can never be sure that you have not forgotten something that will be damaged later.
Since Spring provides XML configuration files in Java Configuration Spring applications, I strongly recommend that you keep all existing Java configurations, write Apache Hadoop sections in xml using the provided namespaces, and simply add a @ImportResource
annotation to your configuration class. Assuming that the spring hadoop configuration is a hadoopContext .xml
at the root of the classpath, you can write:
@Configuration
...
@ImportResource("classpath:/hadoopContext.xml")
public classConfig {
...
}
Alternatively, you can use the @Configuration
wrapper to wrap the XML configuration that you manage for Spring scanning:
@Configuration
@ImportResource("classpath:/hadoopContext.xml")
public class HadoopConfig {
}