1.在pom.xml的<dependencies></dependencies>标签中中加入以下依赖
1 <dependency> 2 <groupId>org.springframework.boot</groupId> 3 <artifactId>spring-boot-starter-web</artifactId> 4 </dependency> 5 6 <dependency> 7 <groupId>org.mybatis.spring.boot</groupId> 8 <artifactId>mybatis-spring-boot-starter</artifactId> 9 <version>2.0.1</version>10 </dependency>11 12 <dependency>13 <groupId>mysql</groupId>14 <artifactId>mysql-connector-java</artifactId>15 <scope>runtime</scope>16 </dependency>17 18 <dependency>19 <groupId>com.alibaba</groupId>20 <artifactId>druid</artifactId>21 <version>1.1.10</version>22 </dependency>
2.把resource包下的application.properties复制一份再粘贴名字改成application.yml,加入以下内容
1 server: 2 port: 8080 3 servlet: 4 context-path: / 5 spring: 6 datasource: 7 username: root 8 password: 123456 9 url: jdbc:mysql://localhost:3306/mybatis?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=UTC10 type: com.alibaba.druid.pool.DruidDataSource11 driver-class-name: com.mysql.cj.jdbc.Driver
我的数据库密码是123456,数据库名是mybatis