方式一
spring.datasource.url=jdbc:mysql://localhost/clientdb?serverTimezone=UTC
spring.datasource.username=testuser
spring.datasource.password=test
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect
spring.jpa.properties.hibernate.hbm2ddl.auto=validate
方式二
spring.datasource.url=jdbc:mysql://localhost:3306/clientdb?characterEncoding=utf8&useSSL=false&serverTimezone=UTC&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true
spring.datasource.username=testuser
spring.datasource.password=test
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect
spring.jpa.properties.hibernate.hbm2ddl.auto=validate
注意:如果网络连接是公司AD域,则必须用计算名称替代localhost。

本文详细介绍两种在Spring Boot中配置MySQL数据库的方法,包括URL、用户名、密码、驱动类及Hibernate属性等关键信息。
390

被折叠的 条评论
为什么被折叠?



