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删除。



猜您在找 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 Application run failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name spring测试出错:Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0': Spring AOP 报错org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'XXXXXX' defined in class path resource.......... 使用security报错:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springSecurityFilterChain' defined in class path resource org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'multipartResolver': Failed to introspect bean class [org.springframework.web.multipart.commons.CommonsMultipartR org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.jdbc.datasource.DataSourceTransactionManager#0' defined in class path resource [spring-mybat 错误/异常:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/classes/beans_common.xml]...的解决方法
 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM