springboot连接mysql数据库配置文件:
spring:
datasource:
username: root
password: root
url: jdbc:mysql://localhost:3306/user_db?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=UTC
driver-class-name:
我的数据库名字是user_db,用户名和密码都是root。ps:一定记得设置时区!!!
在配置文件的时候,还要在文件添加依赖:
<!--JDBC-->
<dependency>
<groupId></groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>