SpringCloud+MyBatisPlus微服务启动系列异常解决方法

最近,使用Spring Cloud2020.0.0-SNAPSHOT整合Spring Boot2.4.0、MyBatis Plus3.4.1搭建微服务,JDK版本为13.0.2。
启动微服务应用时,出现一系列异常,现将部分罗列如下:

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.4.0)

_ _   |_  _ _|_. ___ _ |    _ 
| | |\/|_)(_| | |_\  |_)||_|_\ 
     /               |         
                        3.4.1 

ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'xxxController': Unsatisfied dependency expressed through field 'xxxFeignService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.edee.xxx.xxx.feign.xxxFeignService': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalancer?

看到最后一句“Did you forget to include spring-cloud-starter-loadbalancer?”,立马想到是否缺少了相关依赖?于是,尝试添加如下依赖:

	<dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-loadbalancer</artifactId>
	</dependency>

重新启动服务,上面的异常不见了。但又出现了新的错误:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-12-16 11:08:07.394 ERROR 32748 --- [           main] o.s.boot.SpringApplication               : Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'growthChangeHistoryController': Unsatisfied dependency expressed through field 'growthChangeHistoryService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'growthChangeHistoryService': Unsatisfied dependency expressed through field 'baseMapper'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.edee.xxx.xxx.dao.GrowthChangeHistoryDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

这个很让人头疼,百思不得其解!
怀着绝望的心情查阅网上各种资料,说法也是五花八门,一一尝试,均不奏效。
但有些文章提到了版本兼容问题,比如就有文章专门指出SpringBoot虽然已经发布了2.4.0版本,但是,不建议大家马上升级,因为版本兼容问题较多。
接下来尝试把SpringBoot降级为2.1.13.RELEASE,重启,又是异常:

Caused by: org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet: file ;
nested exception is java.lang.IllegalArgumentException: Unsupported class file major version 57

根据此异常,查到关键一篇博客:https://www.cnblogs.com/INnoVationv2/p/12349571.html。里面提到:jdk13暂时不被支持,降级至jdk11,可正常运行。
无奈,只能大换血,将JDK降为11.0.9。重启,依然异常:

"C:\Program Files\Java\jdk-11.0.9\bin\java.exe" -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2019.2.4\lib\idea_rt.jar=53833:C:\Program Files\JetBrains\IntelliJ IDEA 2019.2.4\bin" -Dfile.encoding=UTF-8 -classpath C:\Users\Administrator\AppData\Local\Temp\classpath336559354.jar com.edee.xxx.ware.xxxApplication
错误: 找不到或无法加载主类 com.edee.xxx.ware.xxxApplication
原因: java.lang.ClassNotFoundException: com.edee.xxx.ware.xxxApplication

几近崩溃之下,又尝试降低Spring Cloud版本,由2020.0.0-SNAPSHOT降为Greenwich.SR6。这次,终于成功了!

最终版本组合:
Spring Cloud:Greenwich.SR6
Spring Boot:2.1.13.RELEASE
MyBatis Plus:3.4.1
JDK:11.0.9
Nacos:1.4.0
但愿该组合能够稳如泰山啊!
在这里插入图片描述在这里插入图片描述在这里插入图片描述

  • 4
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值