前期准备
首先创建一个web项目,并整合lombok。可以参考之前的文章SpringBoot快速构建web项目-多模块项目
添加依赖
<!--引用AOP-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
业务类
实体类
@Data
public class Salesbill {
private long id;
@JsonFormat(pattern = "yyyy-MM-dd")
private Date date;
private long customerID;
private long categoryID;
private double price;
private double grossWeight;
private double tareWeight;
private String remack;
private long address;
private String createName;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
}
控制器
@RestController
@RequestMapping("Salesbill")
public class SalesbillController {
@GetMapping("{id}"