Use protobuf production template code, use the version:
<dependency> <groupId>com.google.protobuf</groupId> <artifactId>protobuf-java</artifactId> <version>3.6.1</version> </dependency>
hbase version is: 1.2.1-cdh5.1.4.0
If the print maven dependency tree, you can see the hbase protobuf version 2.5.0
In this case packaging does not complain, but once running, an error occurs:
java.lang.ClassNotFoundException: com.google.protobuf.LiteralByteString
So should we solve it?
The answer is to be backward compatible way - is to retain the high version, remove the lower version
The final approach is to remove the low version of dependencies in the maven to me as an example:
<dependency> <groupId>org.apache.hbase</groupId> <artifactId>hbase-client</artifactId> <version>${hbase.version}-${cdh.version}</version> <exclusions> <exclusion> <groupId>org.jboss.netty</groupId> <artifactId>netty</artifactId> </exclusion> <exclusion> <groupId>io.netty</groupId> <artifactId>netty-all</artifactId> </exclusion> <exclusion> <groupId>org.apache.hbase</groupId> <artifactId>hbase-protocol</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.apache.hbase</groupId> <artifactId>hbase-server</artifactId> <version>${hbase.version}-${cdh.version}</version> <exclusions> <exclusion> <groupId>org.jboss.netty</groupId> <artifactId>netty</artifactId> </exclusion> <exclusion> <groupId>io.netty</groupId> <artifactId>netty-all</artifactId> </exclusion> <exclusion> <groupId>org.apache.hbase</groupId> <artifactId>hbase-protocol</artifactId> </exclusion> </exclusions> </dependency>