其他分享
首页 > 其他分享> > Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name &#

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name &#

作者:互联网

在进行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>

问题解决!

标签:selectAll,fundMapper,resource,creating,fms,failed,Controller,public,crm
来源: https://www.cnblogs.com/zjulanjian/p/11058552.html