1.注解的方式

  • Mapper

public interface UserMapper extends BaseMapper { @Select(“select * from tb_user”) List findAll();}

  • 测试

@Test void testFindALl() { List all = userMapper.findAll(); System.out.println(all); }

2. 使用XML的方式

  • Mapper

List findAllXml();

  • MapperXml

<?xml version=”1.0” encoding=”UTF-8” ?><!DOCTYPE mapper PUBLIC “-//mybatis.org//DTD Mapper 3.0//EN” “http://mybatis.org/dtd/mybatis-3-mapper.dtd">

  • application.properties

mapperxml文件的位置,默认classpath:/mapper/**/.xml