【问题标题】:Spring - how to connect to database mysqlSpring - 如何连接到数据库mysql
【发布时间】:2020-09-30 18:09:02
【问题描述】:

我正在尝试连接到 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 代码编辑器

【问题讨论】:

    标签: mysql spring spring-boot


    【解决方案1】:

    试试

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

    而不是

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

    【讨论】:

    • 它运行了,但出现了一个登录页面,我无法访问另一个页面。
    • 嗯,这个错误与你的问题无关,你只是修复了一个问题,然后转移到另一个问题。我建议您针对不同的问题打开一个新的 stackoverflow 问题。不客气。
    • 谢谢你们,我会这样做的
    猜你喜欢
    • 2014-03-04
    • 2020-11-20
    • 2018-11-23
    • 1970-01-01
    • 2015-11-13
    • 2015-10-31
    相关资源
    最近更新 更多