遇到的坑
1.在加入spring boot 与dubbo后会出现java.lang.NoClassDefFoundError: com/alibaba/spring/util/PropertySourcesUtils 错误需引入阿里的spring-context-support.jar包maven如下
<dependency>
<groupId>com.alibaba.spring</groupId>
<artifactId>spring-context-support</artifactId>
<version>1.0.2</version>
</dependency>
2.根据官方文档进行注解配置需将@EnableDubbo注解放在SpringBoot应用入口类而不是Dubbo的配置类中
否则程序虽不报错但服务无法注册至zookeeper中
3.使用curator连接zookeeper时应注意自己使用zookeeper版本与curator中依赖的zookeeper.jar版本是否区别过大,过大报KeeperException$UnimplementedException: KeeperErrorCode = Unimplemented forXXXXXX错误
笔者使用的zookeeper为3.4.14可在pom文件中进行如下配置
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
<version>4.2.0</version>
<exclusions>
<exclusion>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.4.14</version>
</dependency>
4.在解决3后可能会遇到Detected both log4j-over-slf4j.jar AND bound slf4j-log4j12.jar on the class path, preempting StackOverflowError. 错误
解决方案在2引入的zookeeper依赖改为
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.4.14</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
网友评论