坑爹指数:🌟🌟🌟🌟🌟
坑爹原因:仅IDEA调试会出现并且未能正常提示错误原因,而使用java -jar xxx.启动服务缺不存在完整类名冲突。
环境:springboot+idea
场景:项目存在包名+类名仅存在大小写不同会导致IDEA无法正常启动服务,但是打印warn日志并未正确提示命名冲突。
复现步骤:
1、在com.test包并新增两个类,一个类命名为HelloTest.class(完整引用com.test.HelloTest),另一个类命名为HelloTEST.class(完整引用com.test.HelloTEST),service对两个类都进行引用。
2、启动服务
3、服务会输出warn日志后关闭服务
Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘HelloTestServiceImpl’: Lookup method resolution failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [com.test.HelloTestServiceImpl] from ClassLoader [sun.misc.Launcher$AppClassLoader@18b4aac2]
解决方案:
重构冲突的类名。