赞
踩
1.创建数据库并建表:使用mysql数据库
2.创建对应的Java实体类:src/com/mybatis/bean/Employee.java
package com.mybatis.bean; public class Employee { private Integer id; private String lastName; //注意这里的lastName与数据库中的字段(last_name)不相同 private String email; private String gender; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getGender() { return gender; } public void setGender(String gender) { this.gender = gender; } @Override public String toString() { return "Employee [id=" + id + ", lastName=" + lastName + ", email=" + email + ", gender=" + gender + "]"; } }
3.创建全局配置文件:mybatis-config.xml (参考官方文档)
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<environments def
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。