spring-boot中的错误总结:

学习spring的路上遇到的一些坑,以此来记录,以免之后重蹈覆辙。

1.Inferred type ‘S’ for type parameter ‘S’ is not within its bound; should extend 'com.example.myspringboot.model.SysApp’

spring-boot整合JPA时遇到的错误

解决方案
首先感谢Roy-Xin博主,方法很有效的解决了问题
1.可能是spring把本的问题,将高版本换成1.5.4的版本。(这个当时也懒得换,烦导包)
2.直接将图中的sysAppDao.findOne(id)改为 sysAppDao.findById(id).get(),或者改为sysAppDao.findById(id).orElse(null)

2.Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: Cannot create PoolableConnectionFactory (The server time zone value ‘Öйú±ê׼ʱ¼ä’ is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support
或者
springboot com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

spring连接数据库时出现的错误,有时候出现的错误时Failed to linked!

解决方案
刚开始查这个错误的时候以为是数据库版本的问题,还有要设置本地数据库的连接超时项,但是都没什么改变,还是报错。
最后发现我的url为jdbc:mysql://127.0.0.1:3306/java-test?characterEncoding=utf-8&useSSL=falsejdbc.driverClassName = com.mysql.cj.jdbc.Driver在这两个地方出了错。



改为jdbc:mysql://127.0.0.1:3306/java-test?serverTimezone=GMT%2B8&useUnicode=yes&characterEncoding=utf-8&useSSL=false就可以了。



在这里插入图片描述
3.The bean ‘xxx’, defined in null, could not be registered. A bean with that name has already been defined in file [E:\java work\myspringboot\target\classes\com\example\myspringboot\mapper\SysMapper.class] and overriding is disabled.

这个错误是在整合jpa的时候遇到的,当时直接和target包中的类重名了,我很郁闷呐,但还是按照系统的解决办法解决了。
在这里插入图片描述

解决方案:
在配置文件中(我的是application.properties文件)中添加配置spring.main.allow-bean-definition-overriding=true启用覆盖就可以了。有时候也可能是bean的名称重名了,更改其中一个bean的名字也是可以的。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值