通过bean属性表达的不满意的依赖性#sqlSessionFactory'

时间:2015-11-14 17:26:47

标签: spring spring-mvc mybatis spring-mybatis

我有很多DAO定义如下:

  

IxxxDAO

我正在使用 MyBatis ,这是我的配置:

@Configuration
@MapperScan(basePackages = {
        "com.dounets.app.adm.**.dao",
        "com.dounets.app.pi.bil.**.dao",
        "com.dounets.app.pi.common.**.dao",
        "com.dounets.app.pi.dd.**.dao",
        "com.dounets.app.pi.dm.**.dao",
        "com.dounets.app.pi.dmv2.**.dao",
        "com.dounets.app.pi.pim.**.dao",
        "com.dounets.app.pi.report.**.dao",
        "com.dounets.app.pi.tat.**.dao",
        "com.dounets.app.pi.ui.**.dao",
        "com.dounets.app.process.dao",
})
public class MyBatisConfiguration {
    @Bean
    public SqlSessionFactory sqlSessionFactory(DataSource dataSource, ApplicationContext applicationContext) throws Exception {
        SqlSessionFactoryBean sessionFactoryBean = new SqlSessionFactoryBean();
        sessionFactoryBean.setDataSource(dataSource);
        sessionFactoryBean.setMapperLocations(applicationContext.getResources("classpath:mapper/*.xml"));
        return sessionFactoryBean.getObject();
    }
}

如果我评论出一些软件包,它工作正常。但如果我扫描所有包,它会抛出异常:

Unsatisfied dependency expressed through bean property 'sqlSessionFactory'

完整错误:

Unsatisfied dependency expressed through bean property 'sqlSessionFactory': :
 Error creating bean with name 'IAdmCmtUsrLikeDAO' defined in file [IAdmCmtUsrLikeDAO.class]:

我试图扫描每个包,所有包都没问题。

让我看看我的样本IxxxDAO:

public interface IAdmCmtUsrLikeDAO extends IApplicationDAO {

    int delete(AdmCmtUsrLikeVOKey data) throws SQLException;

    int insert(AdmCmtUsrLikeVO data) throws SQLException;

    List<AdmCmtUsrLikeVO> select() throws SQLException;

    AdmCmtUsrLikeVO select(AdmCmtUsrLikeVOKey data) throws SQLException;

    int update(AdmCmtUsrLikeVO data) throws SQLException;

    int update(HashMap<String, Object> data) throws SQLException;
}

1 个答案:

答案 0 :(得分:0)

如果您收到此异常,请在日志中的某处查找“注入自动连接的依赖项失败”。那应该是你的问题。我也有同样的错误。

更多信息: https://bethelwhite.wordpress.com/2015/10/16/mybatis-spring-trouble-is-there-an-unresolvable-circular-reference-may-be-a-misleading-message/