2 zr519 zr519 于 2016.01.22 20:03 提问

求助Spring-boot Mybatis问题

单个Mapper都可以扫到,正常运行,就是两个放同一个目录下,就报错了,求解,下面是我的代码@Configuration
@MapperScan(basePackages={"cn.com.bsfit.frms.ds.mapper"},sqlSessionFactoryRef="dsSqlSessionFactory")
public class DsDataSourceConfig {

@Bean
@ConfigurationProperties(prefix = "frms.merchants.ds")
public DataSource dsDataSource() {
    return DataSourceBuilder.create().build();
}

@Bean
public SqlSessionFactory dsSqlSessionFactory(@Qualifier("dsDataSource")DataSource dsDataSource) throws Exception {
    if (dsDataSource != null) {
        SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
        bean.setDataSource(dsDataSource);
        bean.setConfigLocation(new ClassPathResource("DSMybatisConfig.xml"));
        return bean.getObject();
    }
    return null;
}

@Bean
public DataSourceTransactionManager dsTransactionManager(@Qualifier("dsDataSource")DataSource dsDataSource){
    if(dsDataSource!=null)
        return new DataSourceTransactionManager(dsDataSource);
    return null;
}

@Bean
public DSPayOrderMapper dsPayOrderMapper() throws Exception {
  SqlSessionTemplate sessionTemplate = new SqlSessionTemplate(dsSqlSessionFactory()));
  return sessionTemplate.getMapper(DSPayOrderMapper.class);
}

}

下面是错误信息
19:46:34.272 [main] WARN o.s.b.f.s.DefaultListableBeanFactory - Bean creation exception on FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'DSPayOrderMapper' defined in file [D:\WORK\eclipse-4.5\workspace\frms-merchant\target\classes\cn\com\bsfit\frms\ds\mapper\DSPayOrderMapper.class]: Cannot resolve reference to bean 'dsSqlSessionFactory' while setting bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'dsSqlSessionFactory': Requested bean is currently in creation: Is there an unresolvable circular reference?
19:46:34.388 [main] WARN o.s.b.f.s.DefaultListableBeanFactory - Bean creation exception on FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'DSPayOrderMapper' defined in file [D:\WORK\eclipse-4.5\workspace\frms-merchant\target\classes\cn\com\bsfit\frms\ds\mapper\DSPayOrderMapper.class]: Cannot resolve reference to bean 'dsSqlSessionFactory' while setting bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'dsSqlSessionFactory': Requested bean is currently in creation: Is there an unresolvable circular reference?

2个回答

qq_28623333
qq_28623333   2016.01.22 20:05

uuuy啊打发范德萨恶法的我啊

q1305882275
q1305882275   2016.08.29 11:31

spring-boot国内很少啊

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!