-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
多mapper注入时,该项目会报BeanCurrentlyInCreationException,Is there an unresolvable circular reference?警告 #2
Comments
包含两个吗?我测试过两个没问题。。 |
包含2个,我是在原基础上增加了一个实体类,一个mapper和一个mapper.xml文件,就会出现上述问题,增加方式有不一样的地方吗?或者是否能提供该项目为多个mapper的情况 |
我会增加多个mapper. |
期待您的多mapper模式 |
我在项目中又新增了2个表和对应的实体、Mapper,你可以下载最新代码试试这个问题。 |
赞,赶紧更新做了尝试,发现问题依旧,启动后会出现WARN,并且每个mapper重复3遍。 本次完全重新pull,仅修改了数据库连接地址和端口,感觉问题很诡异,附加本次相关的环境信息及日志,希望有所帮助。pom文件没有动过。另求一下您的编译环境。感觉这个问题很诡异,使用IDEA和mvn编译结果都一样。相关信息如下: mac os X Yosemite 编译环境: java -version mvn -version 以下是日志信息:
|
我发个我这里的日志,也有警告:
|
原来同有,我一开始想解决这个WARN,跟踪spring代码跟的晕了,对于会重复加载固定的3遍比较困惑,跟踪发现主要是在sqlSessionFactory加载时报错。不过在换为官方的spring-mybatis时,却没有该警告,不知道是不是和tk包里的MapperScannerConfigurer实现有关系。 |
我找时间和mybatis-starter对比看看。 |
这个bug是mybatis-spring的,换到最新的1.2.4版本就没问题了。 详细内容看这里:mybatis/spring#58 |
赞,已更新1.2.4尝试,并且需将通用mapper升级为3.3.6后,启动无warn。 |
today, i meet the same problem ,but when i try
this problem gone away, i guess this bug is belong to mybatis-spring |
hi,abel533,我下载了本demo项目,在使用单个mapper时没有报这个警告错误,但是当把mapper增加为2个以上时,就会报该异常信息,不知具体的原因。
跟踪代码,看到会优先执行MyBatisMapperScannerConfig扫描,虽然设置了AutoConfigureAfter,MyBatisMapperScannerConfig修改definition.setBeanClass(MapperFactoryBean.class)后,spring在做dataSourceInitializerPostProcessor处理时,会抛出该异常,不知道哪里出了问题。而且会重复出现2,3边同样的WARN,百分百重现。
WARN 43180 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Bean creation exception on FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'subCountryMapper' defined in file [/tt/fsm/target/classes/com/lmtest/fsm/mapper/SubCountryMapper.class]: Cannot resolve reference to bean 'sqlSessionFactory' while setting bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'sqlSessionFactory': Requested bean is currently in creation: Is there an unresolvable circular reference?
The text was updated successfully, but these errors were encountered: