mysql安装 docker-compose.yml内容
version: '3'
services:
mysql-db:
container_name: mysql5.7
image: mysql:5.7
ports:
- "13306:3306"
environment:
MYSQL_ROOT_PASSWORD: "root"
- TZ=Asia/Shanghai
command:
--wait_timeout=31536000
--interactive_timeout=31536000
--max_connections=1000
volumes:
- "./mysql/data: /var/lib/mysql"
- "./mysql/config: /etc/mysql/conf.d"
maven 换源 setting.xml
alimaven aliyun maven http://maven.aliyun.com/nexus/content/groups/public/ central
排除自动配置bean @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
pom.xml 配置druid和Hibernate验证
com.github.drtrang druid-spring-boot2-starter1.1.10 org.springframework.boot spring-boot-starter-validation2.5.5 com.baomidou mybatis-plus-boot-starter3.4.3.4
BaseDO
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@TableName(value ="tag")
@Data
public class Tag implements Serializable {
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@TableField(value = "name")
private String name;
@TableField(value = "createTime")
private Date createTime;
@TableField(value = "isDelete")
private Byte isDelete;
@TableField(value = "updateTime")
private Date updateTime;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
Tag other = (Tag) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
&& (this.getIsDelete() == null ? other.getIsDelete() == null : this.getIsDelete().equals(other.getIsDelete()))
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
result = prime * result + ((getIsDelete() == null) ? 0 : getIsDelete().hashCode());
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
return result;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", name=").append(name);
sb.append(", createTime=").append(createTime);
sb.append(", isDelete=").append(isDelete);
sb.append(", updateTime=").append(updateTime);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
}
自动生成实体类
响应基类
import lombok.Data; @Data public class BaseResponse{ private int code; private T data; private String message; public BaseResponse(int code, T data, String message) { this.code = code; this.data = data; this.message = message; } }
响应工具类
public class ResultUtils {
public static BaseResponse success(T data) {
return new BaseResponse<>(0, data, "ok");
}
public static BaseResponse error(int code, String errorMessage) {
return new BaseResponse<>(code, null, errorMessage);
}
}



