異常詳情
Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name xxxxx
Lookup method resolution failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [classA] from ClassLoader [sun.misc.Launcher$AppClassLoader@14dad5dc]
原因
此異常原因是因為classA中使用了項目沒有導入的類,從而導致類加載失敗。一般來說如果使用了沒有依賴的類應該會報ClassNotFindException的錯誤,但是如果只是導入卻沒有使用的使用可能就會報此錯誤。
通常此錯誤見與使用maven框架配置了第三方類的scope是provided的情況下。筆者在使用spring boot、maven時導致此錯誤。
解決辦法
檢查classA類中可能存在的沒有依賴的類或者包,將之導入(或者加入maven依賴、或調整依賴的包中的依賴的scope),總之使其類加載器能夠在當期classPath找到此類即可。
原文地址:https://blog.csdn.net/huitoukest/article/details/88013763https://blog.csdn.net/huitoukest/article/details/88013763