報錯Caused by: java.lang.NoSuchMethodException: com.imooc.ioc.injection.service.InjectionServiceImpl.<init>()
在InjectionServiceImpl類里面構(gòu)造注入和設(shè)值注入同時存在,把spring-injection.xml文件中的構(gòu)造注入配置注釋掉,運行TestInjection類里面的testSetter()設(shè)值注入方法,報異常
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'injectionService' defined in class path resource [spring-injection.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.imooc.ioc.injection.service.InjectionServiceImpl]: No default constructor found; nested exception is java.lang.NoSuchMethodException: com.imooc.ioc.injection.service.InjectionServiceImpl.<init>()
2018-06-06
你在xml文件中用ctrl+鼠標(biāo)移動到com.imooc....這一塊看一下你的路徑有沒有出錯。
2017-12-04
把構(gòu)造注入那段代碼注釋掉看看呢?會不會是在getBean的時候構(gòu)造注入但xml里沒有構(gòu)造注入的配置造成的