问题|启动Spring Boot报错-4处 @Spring Boot
描述
说明:
- 工具:IntelliJ IDEA工具
- 时间:2021.1.10 @艾伦
- 记录:搭建好Spring Boot框架及基本配置后,启动Spring Boot项目,结果出现许多问题,在此记录下来,方便日后遇到相关问题时,更好的解决
问题
问题1:Application failed to start with classpath
错误:
15:41:19.809 [main] DEBUG org.springframework.boot.devtools.restart.ChangeableUrls - Matching URLs for reloading : [file:/D:/All_Projects/Blog/Blog_back-IDEA/bolg/target/classes/]
15:41:20.030 [restartedMain] DEBUG org.springframework.boot.logging.ClasspathLoggingApplicationListener - Application failed to start with classpath: [file:/D:/All_Projects/Blog/Blog_back-IDEA/bolg/target/classes/]
具体:
解决:
- 检查配置文件,发现有错误的冒号,修改即可
低级错误
效果:
问题2:Unable to load authentication plugin ‘caching_sha2_password’
错误:
ERROR 23072 --- [ restartedMain] o.a.tomcat.jdbc.pool.ConnectionPool : Unable to create initial connections of pool.
java.sql.SQLException: Unable to load authentication plugin 'caching_sha2_password'.
具体:
解决:
参考:https://blog.csdn.net/w605283073/article/details/88096598
- 更新mysql驱动的jar版本,如:修改为8.0.11版本
版本问题
结果:(新问题的解决见→问题3)
问题3:The server time zone value ‘Öйú±ê׼ʱ¼ä’ is unrecognized or represents more than one time zone
新问题:
java.sql.SQLException: 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.
解决:
- 在jdbc的连接 url 部分加上 serverTimezone=UTC
时区问题
结果:项目启动成功!!!只出现警告
警告4:Loading class ‘com.mysql.jdbc.Driver’. This is deprecated
参考:https://blog.csdn.net/weixin_42323802/article/details/82500458
警告-1: 驱动弃用
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'.
The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
具体:
解决-1:
- 数据库驱动‘com.mysql.jdbc.Driver’已经被弃用,需使用新的驱动com.mysql.cj.jdbc.Driver’
- 在jdbc的相关配置中,将com.mysql.jdbc.Driver 改为 com.mysql.cj.jdbc.Driver
警告-2: SSL连接
Sun Jan 10 20:49:14 CST 2021 WARN: Establishing SSL connection without server's identity verification is not recommended.
According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set.
For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'.
You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
具体:
解决-2:
- 由于新版的mysql会询问是否SSL连接,并返回一个Boolean值
- 所以需要手动配置true或false,来告知SSL是否连接(如:useSSL=false)
结果:警告消失
小工具推荐
YAML、YML在线编辑器(格式化校验)解析工具
https://www.toolfk.com/tool-format-yaml