记一次nacos版本踩坑记录
开发意图springboot+nacos搭建服务发现中心;
开发准备:springboot-2.1.11.RELEASE, nacos-2.2.1.RELEASE,cloud-Greenwich.SR4
启动类
@SpringBootApplication
@EnableDiscoveryClient
public class ProvideApplication {
public static void main(String[] args) {
SpringApplication.run(ProvideApplication.class, args);
}
}
报错信息
java.lang.IllegalStateException: Error processing condition on com.alibaba.cloud.nacos.discovery.reactive.NacosReactiveDiscoveryClientConfiguration.nacosReactiveDiscoveryClient ........
Caused by: java.lang.IllegalStateException: @ConditionalOnMissingBean did not specify a bean using type, name or annotation and the attempt to deduce the bean's type failed.......
Caused by: org.springframework.boot.autoconfigure.condition.OnBeanCondition$BeanTypeDeductionException: Failed to deduce bean type for com.alibaba.cloud.nacos.discovery.reactive.NacosReactiveDiscoveryClientConfiguration.nacosReactiveDiscoveryClient....
Caused by: java.lang.NoClassDefFoundError: org/springframework/cloud/client/discovery/ReactiveDiscoveryClient
Caused by: java.lang.ClassNotFoundException: org.springframework.cloud.client.discovery.ReactiveDiscoveryClient
解决
1、查看springboot版本太低,提升至springboot-2.3.2.RELEASE再次启动;
报错信息:java.lang.IllegalArgumentException: Could not find class [org.springframework.cloud.client.discovery.composite.reactive.ReactiveCompositeDiscoveryClientAutoConfiguration]
Caused by: java.lang.ClassNotFoundException: org.springframework.cloud.client.discovery.composite.reactive.ReactiveCompositeDiscoveryClientAutoConfiguration
2、更改cloud版本Hoxton.SR4,再次启动。完美启动
总结:springboot版本低于nacos版本会出现异常;最终解决版本springboot-2.3.2.RELEASE, cloud-Hoxton.SR4,nacos-2.2.1.RELEASE