Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'fundService': Injection of resource dependencies failed;


在進行SSM的Controller的編寫, 從瀏覽器訪問后端Controller的時候遇到了這個問題. 

這個問題的描述: 創建Bean的對象失敗

錯誤代碼如下: 

@Service("fundService") public class FundServiceImpl implements FundService { @Source private FundMapper fundMapper; @Override public List<Fund> selectAll() { return fundMapper.selectAll(); } }

找了很久的問題, 才發現原來是因為新的項目簡稱為fms, 而原來的項目簡稱為crm

而在數據庫配置的時候, 沒有修改

       <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
              <property name="basePackage" value="com.bj186.crm.mapper"></property>
              <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
       </bean>

解決辦法: 將項目名修改, 把crm修改為fms

       <!--通過bean配置自動掃描並加載mapper-->
       <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
              <property name="basePackage" value="com.bj186.fms.mapper"></property>
              <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
       </bean>

問題解決!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



猜您在找 【解決方案】 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userHandler': Injection of resource dependencies failed; org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'xtCsDao': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanC org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.facto SpringBoot 報 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bootstrapImportSelectorConfiguration': Initialization of bean failed; org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configurationPropertiesBeans' defined in class path resource 【報錯】org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'webSocketHandlerMapping' defined in class path resource org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisConnectionFactory' defined in class path resource Application run failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name
 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM