Spring-如何连接到数据库MySQL

时间:2020-09-30 18:09:02

标签: mysql spring spring-boot

我正在尝试连接到mysql数据库,但无济于事。我把mysql和spring boot的依赖关系启动了jdbc和jpa。

enter image description here

我在aplciation.properties中添加了以下几行。

spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql://localhost:3306/springone 
spring.datasource.username=root
spring.datasource.password=
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

我正在使用xampp,门是3306。

当我运行项目时,控制台上会出现很多内容。我从最后开始打印。

enter image description here

我正在使用Visual Studio代码编辑器

1 个答案:

答案 0 :(得分:1)

尝试

spring.datasource.url=jdbc:mysql://localhost:3306/springone?serverTimezone=UTC

代替

spring.datasource.url=jdbc:mysql://localhost:3306/springone
相关问题