1

我有很多这样定义的 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;
}
4

1 回答 1

0

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

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

于 2016-02-26T17:07:27.153 回答