在抽象接口编辑注解

@Select("select * from user")
    List<User> getUsers();

 

在mybatis-config.xml即mybatis核心配置文件中绑定接口

 <!--绑定接口-->
    <mappers>
        <mapper class="com.zlc.dao.UserMapper"/>
    </mappers>

注意:简单sql语句推荐使用注解,复杂sql语句使用xml配置文件方式

 

 

目录结构

[MyBatis]注解

 

 

 

接口

package com.zlc.dao;

import com.zlc.pojo.User;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface UserMapper {

    @Select("select * from user")
    List<User> getUsers();
}
View Code

相关文章:

  • 2022-12-23
  • 2022-03-05
  • 2021-09-03
  • 2021-06-10
  • 2021-10-06
  • 2021-09-10
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-10
  • 2021-10-28
  • 2021-05-05
  • 2022-12-23
相关资源
相似解决方案