IDEA搭建spring boot一系列报错解决

最近新建一个Spring Boot项目使用maven的install一启动就报错Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project demo: There are test failures.
在这里插入图片描述
下面有两句提示,打开百度翻译
在这里插入图片描述
点击对应的报告结果
在这里插入图片描述
打开报告文件,这里报错原因大概是dataSource未配置
在这里插入图片描述
在SpringBoot对应的application.properties配置#Mysql的链接
在这里插入图片描述
再次进行maven的install操作,抛出了下面错误信息

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.
2020-06-09 09:07:13.838  INFO 13932 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2020-06-09 09:07:13.870  INFO 13932 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2020-06-09 09:07:13.880  WARN 13932 --- [           main] com.zaxxer.hikari.util.DriverDataSource  : Registered driver with driverClassName=com.mysql.jdbc.Driver was not found, trying direct instantiation.
2020-06-09 09:07:15.215 ERROR 13932 --- [           main] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Exception during pool initialization.

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.

从上面错误信息可以看出com.mysql.cj.jdbc.Driver是mysql驱动包为8.0才有的,找到maven对应的jar包,果然是8.0,这时修改一下mysql配置
在这里插入图片描述
把com.mysql.jdbc.Driver修改成com.mysql.cj.jdbc.Driver
在这里插入图片描述
然后上面还有一个sql异常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.
这里修改mysql对应的时区即可解决,以下为最终配置

#MYSQL连接配置
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/fio1?serverTimezone=UTC
spring.datasource.username=root
spring.datasource.password=root

这时继续启动maven的install,项目成功跑动没有报错
在这里插入图片描述

### 解决 IDEA 创建 SpringBoot 项目时连接超时的问题 当使用 IDEASpring Initializr 创建 Spring Boot 项目时常会遇到连接超时的情况,这通常是因为网络不稳定或代理设置不正确所致。以下是几种有效的解决方案: #### 更改默认的初始化器地址 有时官方服务器响应较慢或是国内访问受限,可以尝试更换为阿里云提供的镜像站点来加速下载过程。 ```xml <!-- 修改settings.xml文件 --> <mirror> <id>aliyunmaven</id> <mirrorOf>*</mirrorOf> <name>Aliyun Maven</name> <url>https://maven.aliyun.com/repository/public</url> </mirror> ``` 对于IDEA内置配置,则可以在`File | Settings... | Build, Execution, Deployment | Build Tools | Maven | Repositories`中添加新的仓库链接[^1]。 #### 配置本地代理 如果工作环境处于内网环境中,可能需要配置HTTP/HTTPS代理才能正常联网获取资源。进入`File -> Settings -> Appearance & Behavior -> System Settings -> HTTP Proxy`,选择自动检测或者手动输入代理服务器信息并测试连通性[^2]。 #### 利用命令行工具代替图形界面操作 考虑到IDE本身可能存在某些兼容性问题影响到插件功能发挥,在这种情况下不妨借助CLI(Command Line Interface)完成同样的任务。安装JDK之后打开终端执行如下指令即可快速搭建起一个新的Spring应用程序框架结构[^3]。 ```bash curl https://start.spring.io/starter.zip -d dependencies=web,jpa,h2 \ -d bootVersion=2.7.0 -d baseDir=demo -o demo.zip && unzip demo.zip && cd demo ``` 以上方法能够有效缓解由于网络因素引发的一系列麻烦事,提高开发效率的同时也减少了不必要的等待时间。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值