- 在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
最新推荐文章于 2024-03-08 15:51:16 发布