Spring Cloud常见问题

Spring Cloud常见问题

ruoyi-cloud版本

*初次使用请一定要参考博客码云项目RuoYi-Cloud启动跳坑指南

1. RuoYiSystemApplication启动失败,数据库连接失败

在这里插入图片描述

  • 原因:无法通过ry-config中ruoyi-system-dev.yml获取正确的jdbc连接
  • 解决方案:检查默认的配置中是否和当前物理机的数据库情况一致,可能本地的数据库账号密码和ruoyi-config中默认的不一致,修改一致后重启即可。我的情况是ry-config在云数据库中,所以需要修改成云数据库的地址和密码。方式如下:在这里插入图片描述

2.nacos 客户端无法连接

确保nacos client >=nacos server的版本即可

3.启动时候Invalid bound statement (not found):..mapper.SysConfigMapper.selectConfigList 报错

  • 原因:有可能是配置文件未加载到导致或者bean注入失败。其实是nacos-server并未读取到配置
  • 解决方法:不使用nacos的内置数据库,而是连接到ruoyi-config所在的数据库,加载到相应的配置即可。正确加载的nacos-dashboard页面如下:在这里插入图片描述

4.集成MPP后@TEST类运行报错:Error creating bean with name ‘com.ruoyi.test.RuoyiTestApplicationTests’: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘com.ruoyi.test.mapper.ITestEntityMapper’ available: expected at least 1 bean which qualifies as autowire candidate.

org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘com.ruoyi.test.RuoyiTestApplicationTests’: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘com.ruoyi.test.mapper.ITestEntityMapper’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@javax.annotation.Resource(shareable=true, lookup=, name=, description=, authenticationType=CONTAINER, type=class java.lang.Object, mappedName=)}
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessProperties(CommonAnnotationBeanPostProcessor.java:332)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1431)

  • 原因:IxxMapper注入失败,调用时找不到
  • 解决办法:启动类扫描这些包并进行注入。启动类加入注解
    @MapperScan(basePackages = "com.ruoyi.test.mapper")
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值