第一步:
第二步:
第三步: 第四步:
pom文件配置:
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.3.4.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> <exclusions> <exclusion> <groupId>org.junit.vintage</groupId> <artifactId>junit-vintage-engine</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.4.2</version> </dependency> <!--mysql驱动--> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency> <dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-all</artifactId> <version>5.5.4</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-autoconfigure</artifactId> </dependency> <dependency> <groupId>com.github.xiaoymin</groupId> <artifactId>knife4j-spring-boot-starter</artifactId> <!--在引用时请在maven*仓库搜索3.X最新版本号--> <version>3.0.2</version> </dependency> <dependency> <groupId>com.github.xiaoymin</groupId> <artifactId>knife4j-springdoc-ui</artifactId> <!--在引用时请在maven*仓库搜索3.X最新版本号--> <version>3.0.2</version> </dependency> <!-- https://mvnrepository.com/artifact/org.projectlombok/lombok --> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.16</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-cache</artifactId> </dependency> </dependencies>
第五步:
配置application.yml文件:
server: # 服务器端口 port: 8880(随便设置) spring: datasource: url: jdbc:mysql://localhost:3306/(数据库名)?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai username: root(数据库用户) password: 123456(数据库密码) driver-class-name: com.mysql.cj.jdbc.Driver devtools: restart: poll-interval: 2s quiet-period: 1999ms mybatis: #mapper文件 mapper-locations: classpath:mapper/*.xml configuration: map-underscore-to-camel-case: true mybatis-plus: configuration: #打印SQL语句 log-impl: org.apache.ibatis.logging.stdout.StdOutImpl swagger: enable: true
第六步:
第七步:测试
第八步:验证
搞定!