源码地址:https://github.com/ostars/springboot-fast.git
摘要
文章主要介绍了如何搭建一个springboot项目,并封装常用的增删查改操作。本文主要包括一下部分:
1、springboot项目搭建步骤
2、通用mapper、model、service的封装
3、通用模块的使用
一、springboot搭建步骤
1.选择spring initializr

2.填写group id和artifact id

3.选择依赖

4.选择项目路径

5.搭建完成后的项目结构

二、springboot通用mapper、model、service的封装
Model.java
package org.ostars.springbootfast.common.model;
import java.util.Date;
/**
* @author isaac
* @date 2019/10/8
*/
public interface Model {
Long getId();
void setId(Long id);
Date getCreateTime();
void setCreateTime(Date createTime);
}
BaseModel.java
package org.ostars.springbootfast.common.model;
import java.util.Date;
/**
* common model
*
* @author isaac
* @date 2019/10/8
*/
public abstract class BaseModel implements Model {
public Long id;
public Date createTime;
}
BaseMapper.java
package org.ostars.springbootfast.common.mapper;
import java.util.List;
/**
* common mapper
*
* @author isaac
* @date 2019/10/8
*/
public interface BaseMapper<T> {
int deleteById(Long id);
int deleteByIds(List<Long> ids);
int insert(T model);
int insertList(List<T> models);
T selectById(Long id);
List<T> selectByModel(T model);
int updateByIdSelective(T model);
int updateById(T model);
}
BaseService.java
SpringBoot快速入门:搭建与集成通用Mapper

本文详述了如何搭建SpringBoot项目,并封装通用Mapper、Model和服务。内容涵盖SpringBoot的搭建步骤、通用模块的封装(包括Model、BaseMapper和Service)以及具体使用示例,旨在简化增删查改操作。
最低0.47元/天 解锁文章
1855





