.pom文件
<!-- mybatis-plus --> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.2.0</version> </dependency>
mybatis-plus配置
package com.example.baseproject.config; import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration public class MybatisPlusConfig { @Bean public PaginationInterceptor paginationInterceptor(){ return new PaginationInterceptor(); } }
实体类
package com.example.baseproject.pojo; import com.baomidou.mybatisplus.annotation.*; import com.baomidou.mybatisplus.extension.activerecord.Model; import lombok.Data; import java.math.BigDecimal; /** * 水果实体类 */ @Data @TableName(value="go_fruits",autoResultMap = true) public class FruitsEntity extends Model<FruitsEntity> { /** * id */ @TableId(type = IdType.INPUT) private Integer fId; /** * 水果类型 */ private String fType; /** * 水果名称 */ //增加查询条件 @TableField(condition = SqlCondition.LIKE) private String fName; /** * 水果价格 */ private BigDecimal fPrice; /** * 菜单数量 */ private String fNum; /** * 删除标识 */ @TableLogic @TableField(exist = false) private Integer delFlag; private String createTime; }
service
package com.example.baseproject.service; import com.baomidou.mybatisplus.extension.service.IService; import com.example.baseproject.pojo.FruitsEntity; public interface FruitsService extends IService<FruitsEntity> { }
serviceImpl
package com.example.baseproject.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.example.baseproject.dao.FruitsMapper; import com.example.baseproject.pojo.FruitsEntity; import com.example.baseproject.service.FruitsService; import org.springframework.stereotype.Service; @Service public class FruitsServiceImpl extends ServiceImpl<FruitsMapper, FruitsEntity> implements FruitsService { }
dao
package com.example.baseproject.dao; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.example.baseproject.pojo.FruitsEntity; public interface FruitsMapper extends BaseMapper<FruitsEntity> { }
来源:oschina
链接:https://my.oschina.net/u/4253180/blog/3163842