- 在pom文件中引入
-
<dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>1.3.2</version> </dependency> - 新建接口文件ChannelMapper 在接口上加上@Mapper注解
-
package com.goldnet.bizoc.channelcenter.mapper; import com.goldnet.bizoc.common.po.Channel; import org.apache.ibatis.annotations.Mapper; import java.util.List; @Mapper public interface ChannelMapper { List<Channel> channels(); } - 在resources资源文件夹下创建mapper文件夹,新建ChannelMapper.xml文件
-

- yml文件中配置
-
mybatis: mapper-locations: classpath:mapper/*Mapper.xml #mapper路径 type-aliases-package: com.goldnet.bizoc.common.po #实体类路径
springcloud整合mybatis
最新推荐文章于 2025-05-23 17:14:24 发布
本文详细介绍了如何在Spring Boot项目中整合MyBatis框架,包括在pom文件中引入依赖、创建Mapper接口和XML文件,以及在yml文件中配置Mapper路径和实体类包。通过具体代码示例,帮助读者快速上手MyBatis与Spring Boot的集成。
1359

被折叠的 条评论
为什么被折叠?



