标签:googl 就是 答案 code ase 情况下 高版本 inf net

使用protobuf生产模板代码,使用的版本是:
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>3.6.1</version>
</dependency>
hbase的版本是:1.2.1-cdh5.1.4.0
如果打印maven依赖树的话,可以看到hbase的protobuf版本是2.5.0
这种情况下打包不会报错,但是一旦运行就会出错:
java.lang.ClassNotFoundException: com.google.protobuf.LiteralByteString
那么应该咱么解决?
答案是想办法向下兼容~ , 就是保留高版本,去除低版本
最终做法是在maven中去掉低版本相关依赖,以我的作为例子:
<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>
记一次protobuf和hbase自带protobuf版本冲突的解决
标签:googl 就是 答案 code ase 情况下 高版本 inf net
原文地址:https://www.cnblogs.com/niutao/p/11122431.html