1、引入基本依赖
1)在jar包下,添加如下信息
<dependencies> //mysql依赖 <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency> //操作数据库工具,jpa依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> //该依赖能省略实体中的get/set方法等功能,能更方便的开发,可选择性依赖 <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> </dependency> </dependencies>
2、mysql数据库的配置
1)appliction.properties改为appliction.yml文件,方便配置
2)在该文件下配置如下信息
spring: datasource: driver-class-name: com.mysql.cj.jdbc.Driver //数据库驱动 username: root //用户名 password: root //账号 //数据库地址,并添加参数配置utf-8防止乱码 url: jdbc:mysql://localhost/wco?characterEncoding=utf-8&useSSL=false&serverTimezone=UTC jpa: show-sql: true //数据库语句打印出来
原文地址:https://www.cnblogs.com/ruanjuyang/p/12252605.html
时间: 2024-11-09 12:06:55