在加载springcloud项目时,使用eclipse加载项目报出了项目中的某些service注入失败的情况:
Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pcAuthenticationSuccessHandler': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'uacUserServiceImpl' defined in file [E:\PROJECT_DUU\OLD_FCC_ONLINE\saascloud-api-master\saascloud-usercenter\target\classes\com\zz\saascloud\provider\service\impl\UacUserServiceImpl.class]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Unexpected AOP exception; nested exception is java.lang.LinkageError: loader constraint violation: when resolving overridden method "com.zz.saascloud.provider.service.impl.UacUserServiceImpl975b2448.getMapper()Ltk/mybatis/mapper/common/Mapper;" the class loader (instance of org/springframework/boot/devtools/restart/classloader/RestartClassLoader) of the current class, com/zz/saascloud/provider/service/impl/UacUserServiceImpl975b2448, and its superclass loader (instance of sun/misc/Launcher$AppClassLoader), have different Class objects for the type tk/mybatis/mapper/common/Mapper used in the signature
项目初始化失败后,又仔细查看了报错 :
以为是包扫描的范围没有覆盖到,又看到关于aop的一些报错 :
于是找到相应的类,进行注释运行,发现还是一样的报错,所以发现是自己查找问题的方式有问题。
把项目放到idea中进行加载,却正常加载了并运行。
于是又找问题,有论坛上说是devtool在低版本的springcloud中bug,导致eclipse加载项目在初始化时会发运行类异常,设置eclipse的debug选项就可以避免这个问题产生 :
发现还是没有解决问题。
既然还是没有解决问题,又找到问题产生的根本,于是想到直接把这个热加载的jar直接给删除掉,果然删除之后eclipse运行项目成功 ,自此问题解决 !