1.错误
Error creating bean with name ‘stuController’: Unsatisfied dependency expressed through field ‘stuService’; nested exception is org.springframework.beans.factory:
解决方法:
添加依赖:
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.9</version>
</dependency>
2.错误
2021-11-28 14:24:10.661 ERROR 4136 --- [reate-942444738] com.alibaba.druid.pool.DruidDataSource : create connection SQLException, url: jdbc:mysql://localhost:3306/spring?characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true, errorCode 0, state 01S00
解决方法:
在数据库连接地址后面加上 :&serverTimezone=UTC
本文介绍了在SpringBoot应用中遇到的Bean创建失败问题,具体表现为' stuController '依赖注入'stuService'时出错,原因是缺少 Druid 数据源依赖。解决方法是在项目中添加阿里巴巴的 Druid-Spring-Boot-Starter 依赖,并更新数据库连接URL,添加'serverTimezone=UTC'参数以避免时区问题。通过这些步骤,可以成功配置并解决SpringBoot应用启动时的数据库连接异常。
801

被折叠的 条评论
为什么被折叠?



