spring +mybatis,debug时 提示bean不能创建,但run时都正常。

披着虎皮 的石头 2021-01-05 02:10:20
spring +mybatis 中间层,debug调试时,提示 biProductStandardItemDao不能创建。
但仅仅是warn,而不是error。在tomcat 运行时,又是正常的,控制台不报提示。

为什么调试时会 出现warn,而运行时,没有出现提示,且能正常运行,不发生错误。
下面是debug时,具体显示的信息。
我花了很多时间找不到原因。

WARN o.s.b.f.s.DefaultListableBeanFactory - Bean creation exception on FactoryBean type check:
org.springframework.beans.factory.UnsatisfiedDependencyException:

Error creating bean with name 'biProductStandardItemDao'
defined in URL [jar:file:/D:/apache-tomcat-7.0.99/webapps/crm_service_web_war/WEB-INF/lib/
crm-service-business-1.0-SNAPSHOT.jar!/crm/core/quality/dao/BiProductStandardItemDao.class]:

Unsatisfied dependency expressed through bean property 'sqlSessionFactory': :

Error creating bean with name 'sqlSessionFactory' defined in class path resource [conf/spring/spring-datasource.xml]:
Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource';

nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'dataSource' defined in class path resource [conf/spring/spring-datasource.xml]:
Invocation of init method failed; nested exception is java.lang.StackOverflowError;

nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'sqlSessionFactory' defined in class path resource [conf/spring/spring-datasource.xml]:
Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource';


nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'dataSource' defined in class path resource [conf/spring/spring-datasource.xml]:
Invocation of init method failed;
nested exception is java.lang.StackOverflowError
...全文
1336 9 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
引用 7 楼 luj_1768 的回复:
提示说:依赖条件不满足。有可能是:后续开发的代码中,存在与早初代码、逻辑或者语义上的不一致。
一般情况是这个原因。 但这里不是,这里是因为项目规模大, 比如表结构有好几百个时,tomcat debug 初始dao时,会报栈溢出,需要改大栈的分配空间。 因为非常见的错误,有debug启动不了,所以急着去找原因。
luj_1768 2021-01-06
  • 打赏
  • 举报
回复
提示说:依赖条件不满足。有可能是:后续开发的代码中,存在与早初代码、逻辑或者语义上的不一致。
  • 打赏
  • 举报
回复 1
tomcat或spring内存不够大而错误。 在IDEA的tomcat配置页面,在VM option中添加 -Xms128m -Xmx1024m -Xss1500k -XX:PermSize=128m -XX:MaxPermSize=256m
林寿强 2021-06-28
  • 举报
回复
@披着虎皮 的石头 老哥顶呀 解决了我的问题
  • 打赏
  • 举报
回复
引用 4 楼 KeepSayingNo 的回复:
你这个是不是连接的数据库没启动,启动了后试试
上面的项目,tomcat run可以运行,而debug不能运行,排除数据库启动或连接问题。 这几天关注 debug时的异常信息,检查java文件 dao.xml、项目配置文件,都找不出问题。 同时拿出以前源代码备份,重新编译运行。 只有最早期备份可以运行和调试正常。 另外我发现debug调试时,提示错误的dao文件, 是整个项目中最后几个mapper配置文件。 再拿错误信息中的,几个重复的报错语句到百度找答案, 都不符合。 最后查到 错误信息中的 StackOverflowError, 然后网上资料说,引起这个错误的是: 1 程序中死循环,或者两个函数相互调用死循环。或 太多的循环,几千 几万个。 2 tomcat或spring的运行或配置的内存不够大,而引起的错误。 那最大的原因,就是测试环境下,tomcat配置的内存未配置,而随着项目规模大而启动时内存溢出。
KeepSayingNo 2021-01-05
  • 打赏
  • 举报
回复
你这个是不是连接的数据库没启动,启动了后试试
  • 打赏
  • 举报
回复
spring里的配置文件,是这样的。 <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close"> <property name="passwordCallback" ref="dbPasswordCallback"/> <!-- 基本属性 url、user、password --> <property name="connectionProperties" value="password=${jdbc.password}"/> </bean> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="configLocation" value="classpath:conf/myb/mybconfig.xml"/> <!--<property name="typeAliasesPackage" value="com.aa,com.bb" />--> <property name="mapperLocations"> <list> <value>classpath*:mapper/**/*Dao.xml</value> </list> </property> </bean>
  • 打赏
  • 举报
回复
alibaba.druid.pool.DruidDataSource 用了alibaba的druid连接池
  • 打赏
  • 举报
回复
2021-01-05 13:52:32.235 [RMI TCP Connection(3)-127.0.0.1] WARN o.s.b.f.s.DefaultListableBeanFactory - Bean creation exception on FactoryBean type check: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'biProductStandardItemDao' defined in URL [jar:file:/D:/apache-tomcat-7.0.99/webapps/crm_service_web_war/WEB-INF/lib/crm-service-business-1.0-SNAPSHOT.jar!/crm/core/quality/dao/BiProductStandardItemDao.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory': : Error creating bean with name 'sqlSessionFactory' defined in class path resource [conf/spring/spring-datasource.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [conf/spring/spring-datasource.xml]: Invocation of init method failed; nested exception is java.lang.StackOverflowError; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [conf/spring/spring-datasource.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [conf/spring/spring-datasource.xml]: Invocation of init method failed; nested exception is java.lang.StackOverflowError 2021-01-05 13:52:32.762 [RMI TCP Connection(3)-127.0.0.1] INFO c.alibaba.druid.pool.DruidDataSource - {dataSource-2} inited

81,122

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧