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

这里总结的问题,通常啥错误也不报,需要自个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