导学
开发模式
环境搭建![](https://img-blog.csdnimg.cn/direct/5bd33b6c8d8d48438dca54f76d1ac29a.png)
pom文件引入依赖
<dependencies>
<!-- 起步依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- mybatis依赖-->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
<!-- mysql驱动-->
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
</dependency>
</dependencies>
配置application.yml
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/big_event
username: root
password: ****
搭建包结构
搭建启动类
@SpringBootApplication
public class BigEventApplication
{
public static void main( String[] args )
{
SpringApplication.run(BigEventApplication.class,args);
}
}
1.用户接口编写
引入Lombok依赖可以自动生成set get方法
<!-- Lombok依赖-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
具体使用方法(加入@Data注解)
1.1 注册
开发流程
接口文档
因为返回格式都是统一的,所以定义一个类来统一返回
其中
@NoArgsConstructor:构造无参的构造方法
@AllArgsConstructor:构造全参的构造方法
接口思路:
Controller层
Service层
Mapper层
用postman测试: