实体类 package pojo; //实体类 public class User { private int id; private String name; private String pwd; public User() { } public User(int id, String name, String pwd) { this.id = id; this.name = name; this.pwd = pwd; } public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getPwd() { return pwd; } public void setPwd(String pwd) { this.pwd = pwd; } @Override public String toString() { return "User{" + "id=" + id + ", name='" + name + '\'' + ", pwd='" + pwd + '\'' + '}'; } } Dao接口 package com.mu.dao; import com.mu.pojo.User; import java.util.List; public interface UserDao { List<User> getUserList(); } 接口实现类 <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "https://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!--namespqce=绑定一个对应的Mapper接口--> <mapper namespace="com.mu.dao.UserDao"> <!--select查询语句--> <select id="getUserList" resultType="com.mu.pojo.User"> select * from mybatis.user </select> </mapper>
标签:name,代码,id,pwd,User,2.3,编写,public,String From: https://www.cnblogs.com/muzhaodi/p/17808639.html