1.版本
springboot3版本为3.0.2
Server url为 https://start.aliyun.com/
mybatis-plus版本为3.5.3.1
2.引入依赖
3.配置文件
spring.datasource.url=jdbc:mysql://localhost:3306/xxxx?useUnicode=true&autoReconnect=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai
spring.datasource.username=root
spring.datasource.password=xxxx
mybatis.mapper-locations=classpath:mapper/*Mapper.xml
resources/mapper路径下放置*Mapper.xml文件
4.在Application启动类配置扫描mapper路径
@MapperScan("com.xxxx.mapper")
5.实体类
@Data
@TableName("table_name")
public class TableName{
@TableId(type = IdType.AUTO)
private Long pddGoodsId;
private String servTxt;
}
6.mapper类
public interface TableNameMapper extends BaseMapper
}
7.service接口、service类
public interface TableNameService extends IService
}
@Service
public class TableNameServiceImpl extends ServiceImpl
}
8.在controller中引用
@Resource
private TableNameService TableNameService;