本次项目使用idea工具开发,控制层使用springboot,数据库交互层使用mybatis-plus;
使用springboot的好处这里我不再赘述;mybatis-plus在这里做个基本的介绍。相信大家对mybatis已经耳熟能详了;mybatis-plus是一个 MyBatis 的增强工具,在 MyBatis 的基础上只做增强不做改变,为简化开发、提高效率而生。详细介绍请移步到官网MyBatis-Plus
以下是springboot集成mybatis-plus的代码:
pom.xml
com.baomidou
mybatis-plus-boot-starter
${mybatis-plus.version}
com.baomidou
mybatis-plus-generator
${mybatis-plus.version}
compile
application.yml
mybatis-plus:
#mapper.xml的路径
mapper-locations: classpath:mybatis/mapping/*.xml
#实体类扫描,多个包用逗号隔开
type-aliases-package: com.binkai.entity
global-config:
db-config:
db-type: mysql
capital-mode: false #开启大小写命名
column-like: true
servic,这里需要注意service接口需要集成IService类
public interface DepService extends IService {
}
serviceImpl,这里也需要注意serviceImpl需要集成ServiceImpl类
@Service
public class DepServiceImpl extends ServiceImpl implements DepService {
@Autowired
private DepMapper depMapper;
}
Mapper这里也需要注意集成BaseMapper类
public interface DepMapper extends BaseMapper {
}
通过以上配置springboot+mybatis-plus就可以了;使用主要还是在serviceImp中,在这里按照mybatis-plus的查询规则来写我们的代码能减少很过重复的工作。
页面更新:2024-03-20
本站资料均由网友自行发布提供,仅用于学习交流。如有版权问题,请与我联系,QQ:4156828
© CopyRight 2008-2024 All Rights Reserved. Powered By bs178.com 闽ICP备11008920号-3
闽公网安备35020302034844号