问题|启动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.

解决:

参考:https://www.pianshen.com/article/3239164549/

  • 在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
在这里插入图片描述


  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 当使用spring-boot-starter-data-mongodb时,如果启动时出现错误,可能有以下几个原因导致: 1. 依赖版本不匹配:请确认spring-boot-starter-data-mongodb的版本和其他相关依赖的版本是否兼容。可以通过查看官方文档或者其他资源来确认依赖的正确版本。 2. 配置错误:请检查application.properties或application.yml文件中与mongodb相关的配置项是否正确。包括数据库的连接地址、用户名、密码等。如果有特殊字符,可能需要进行转义。 3. 依赖缺失:如果启动报错指明找不到相关的类或方法,可能是由于缺少依赖。请确认是否正确添加了spring-boot-starter-data-mongodb的依赖,并且没有遗漏其他必需的依赖。 4. 数据库连接问题:请确认mongodb数据库是否已经正确启动,并且可以通过提供的连接地址连接到数据库。可以尝试使用mongodb的官方客户端工具来测试连接的可用性。 5. 其他问题:如果以上情况都排除了,可以查看具体的错误日志或异常信息,尝试通过搜索引擎或开发社区寻找类似的问题和解决方案。 总之,在解决spring-boot-starter-data-mongodb启动报错时,需要仔细排查可能的原因,并逐一尝试解决,最终找到问题所在并进行修复。 ### 回答2: 当使用spring-boot-starter-data-mongodb启动项目时遇到错误,可能是由于以下几个原因导致的: 1. 缺少MongoDB依赖:确认在pom.xml文件中添加了正确的MongoDB依赖,例如: ``` <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-mongodb</artifactId> </dependency> ``` 2. MongoDB的配置错误:检查application.properties或application.yml文件中的MongoDB配置,确保配置的是正确的MongoDB地址、端口和数据库名。 3. 缺少MongoDB的驱动程序:在pom.xml文件中添加MongoDB驱动程序的依赖,例如: ``` <dependency> <groupId>org.mongodb</groupId> <artifactId>mongo-java-driver</artifactId> </dependency> ``` 4. MongoDB连接身份验证错误:如果MongoDB设置了身份验证,需要在配置文件中添加相应的用户名和密码,确保登录凭据正确。 5. MongoDB服务未启动:检查MongoDB服务是否已经启动,可以通过命令行或者MongoDB可视化工具来确认。 如果以上步骤都正确无误,仍然无法启动项目并且出现报错,请检查报错信息,并且根据报错信息进一步排查和解决问题

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值