spring无法启动常见原因及排查方法

本文总结了在使用MyBatis和MongoDB时常见的配置错误,包括返回值类型错误、SQL语法问题及MongoDB配置不当导致的bean创建失败。通过在特定代码段设置断点,可以有效定位并解决这些问题。

这里总结的问题,通常啥错误也不报,需要自个debug排查,当然每个人遇到的问题可能是不同的,这里仅仅是我个人帮同事解决问题后的一些总结,可能网上的小伙伴可能也遇到,姑且简单记录一下:

1. mybatis文件配置有问题,比如返回值类型写错了,或者sql语法有问题

排查方法:在AbstractAutowireCapableBeanFactory#doCreateBean 中 几个catch中打断点差不多就能找到问题所在了,归根结底,其实也就是编码的时候仔细一点就行了,但是偶尔也会粗心,但是只要知道排查方法,啥也不惧

2. 还是配置问题,比如mongo配置错了

 

排查方法:ConstructorResolver#autowireConstructor 断点到catch处
Error creating bean with name 'mongo' defined in class path resource [applicationContext-multi-datasource.xml]:
Unsatisfied dependency expressed through constructor argument with index 0 of type [com.mongodb.ServerAddress]:
Could not convert constructor argument value of type [com.mongodb.MongoClientURI] to required type [com.mongodb.ServerAddress]:
Failed to convert value of type 'com.mongodb.MongoClientURI' to required type 'com.mongodb.ServerAddress';
nested exception is java.lang.IllegalStateException: Cannot convert value of type [com.mongodb.MongoClientURI] to required type [com.mongodb.ServerAddress]:
no matching editors or conversion strategy found

*****如果对您有帮助,支持一下-> 去打赏 *****











转载于:https://www.cnblogs.com/hsuchan/p/10525978.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值