框架(一) mybaties

//创建 pojo 
package cn.smbms.pojo;
import java.util.Date;
public class User {
 private Integer id; //id
 private String userCode; //用户编码
 private String userName; //用户名称
 private String userPassword; //用户密码
 private Integer gender;  //性别
 private Date birthday;  //出生日期
 private String phone;   //电话
 private String address; //地址
 private Integer userRole;    //用户角色
 private Integer createdBy;   //创建者
 private Date creationDate; //创建时间
 private Integer modifyBy;     //更新者
 private Date modifyDate;   //更新时间
 
 public Integer getId() {
  return id;
 }
 public void setId(Integer id) {
  this.id = id;
 }
 public String getUserCode() {
  return userCode;
 }
 public void setUserCode(String userCode) {
  this.userCode = userCode;
 }
 public String getUserName() {
  return userName;
 }
 public void setUserName(String userName) {
  this.userName = userName;
 }
 public String getUserPassword() {
  return userPassword;
 }
 public void setUserPassword(String userPassword) {
  this.userPassword = userPassword;
 }
 public Integer getGender() {
  return gender;
 }
 public void setGender(Integer gender) {
  this.gender = gender;
 }
 public Date getBirthday() {
  return birthday;
 }
 public void setBirthday(Date birthday) {
  this.birthday = birthday;
 }
 public String getPhone() {
  return phone;
 }
 public void setPhone(String phone) {
  this.phone = phone;
 }
 public String getAddress() {
  return address;
 }
 public void setAddress(String address) {
  this.address = address;
 }
 public Integer getUserRole() {
  return userRole;
 }
 public void setUserRole(Integer userRole) {
  this.userRole = userRole;
 }
 public Integer getCreatedBy() {
  return createdBy;
 }
 public void setCreatedBy(Integer createdBy) {
  this.createdBy = createdBy;
 }
 public Date getCreationDate() {
  return creationDate;
 }
 public void setCreationDate(Date creationDate) {
  this.creationDate = creationDate;
 }
 public Integer getModifyBy() {
  return modifyBy;
 }
 public void setModifyBy(Integer modifyBy) {
  this.modifyBy = modifyBy;
 }
 public Date getModifyDate() {
  return modifyDate;
 }
 public void setModifyDate(Date modifyDate) {
  this.modifyDate = modifyDate;
 }
}

//mybaties-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">
<!-- 通过这个配置文件完成mybatis与数据库的连接 -->
<configuration>
 <!-- 引入 database.properties 文件-->
 <!-- <properties resource="database.properties"/> -->
 
 <properties>
  <property name="driver" value="com.mysql.jdbc.Driver"/>
  <property name="url" value="jdbc:mysql://127.0.0.1:3306/smbms"/>
  <property name="user" value="root"/>
  <property name="password" value="root"/>
    </properties>
 
 
 <!-- 配置mybatis的log实现为LOG4J -->
 <settings>
  <setting name="logImpl" value="LOG4J" />
 </settings>
 <environments default="development">
  <environment id="development">
   <!--配置事务管理,采用JDBC的事务管理  -->
   <transactionManager type="JDBC"></transactionManager>
   <!-- POOLED:mybatis自带的数据源,JNDI:基于tomcat的数据源 -->
   <dataSource type="POOLED">
    <property name="driver" value="${driver}"/>
    <property name="url" value="${url}"/>
    <property name="username" value="${user}"/>
    <property name="password" value="${password}"/>
   </dataSource>
  </environment>
 </environments>
 
 <!-- 将mapper文件加入到配置文件中 -->
 <mappers>
  <mapper resource="cn/smbms/dao/user/UserMapper.xml"/>
 </mappers>

</configuration>
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值