Springboot 启动报错 The bean 'xxxx', defined in class path resource

本文分享了在使用SpringBoot 2.1.2时遇到的与Druid连接池不兼容的问题及解决方案。作者测试发现当SpringBoot版本为2.0.4时问题得以解决。

错误示例:如下图所示

错误的原因:

是springboot和druid版本不兼容 导致的

测试结果:

当我使用springboot 2.1.2的时候测试发现没有druid可以兼容,均会报以上错误,使用springboot 2.0.4  问题解决

希望我这个分享对大家有帮助,如有不对的地方,敬请指正!!

 

代码报错六月 10, 2025 9:51:26 上午 org.apache.coyote.AbstractProtocol init 信息: Initializing ProtocolHandler ["http-bio-8080"] 六月 10, 2025 9:51:26 上午 org.apache.catalina.core.StandardService startInternal 信息: Starting service Tomcat 六月 10, 2025 9:51:26 上午 org.apache.catalina.core.StandardEngine startInternal 信息: Starting Servlet Engine: Apache Tomcat/7.0.47 六月 10, 2025 9:51:28 上午 org.apache.catalina.core.ApplicationContext log 信息: No Spring WebApplicationInitializer types detected on classpath 六月 10, 2025 9:51:28 上午 org.apache.catalina.core.ApplicationContext log 信息: Initializing Spring root WebApplicationContext log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader). log4j:WARN Please initialize the log4j system properly. 六月 10, 2025 9:51:31 上午 org.apache.catalina.core.StandardContext listenerStart 严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'bookService': Unsatisfied dependency expressed through field 'bookMapper'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'bookMapper' defined in file [D:\ideaworkspace\BookManagementSystem2\target\classes\com\example\book\dao\BookMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [D:\ideaworkspace\BookManagementSystem2\target\classes\mapper\BookMapper.xml]'; nested exception is java.lang.IllegalArgumentException: Mapped Statements collection already contains value for com.example.book.dao.
06-11
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值