首页 > 代码库 > MyBatis应用开发(1)应用之开发环境

MyBatis应用开发(1)应用之开发环境

1. 应用

1.1. 开发环境

MyBatis官方网站:http://www.mybatis.org/

MyBatis3介绍页面:http://www.mybatis.org/mybatis-3/

MyBatis3下载页面:https://github.com/mybatis/mybatis-3/releases

 

本文基于mybatis-3.4.2这个版本来编写,使用的jar包包括:

 

(1)Mybatis框架:

mybatis-3.4.2.jar

 

(2)依赖的第三方库:

ant-1.9.6.jar              

ant-launcher-1.9.6.jar

asm-5.1.jar                

cglib-3.2.4.jar

commons-logging-1.2.jar    

javassist-3.21.0-GA.jar

log4j-1.2.17.jar           

log4j-api-2.3.jar

log4j-core-2.3.jar         

ognl-3.1.12.jar

slf4j-api-1.7.22.jar       

slf4j-log4j12-1.7.22.jar

 

(3)数据库的JDBC驱动库。

本文基于mysql

mysql-connector-java-5.1.40-bin.jar

 

 

1.2. 数据库准备

 数据库的表和测试数据准备:

mysql> create database mybatis;

Query OK, 1 row affected (0.06 sec)

 

mysql> use mybatis;

Database changed

mysql> create table t_person  ( id varchar(64) primary key, name varchar(64) not null, status integer not null

Query OK, 0 rows affected (0.11 sec)

 

mysql> desc t_person;

+--------+-------------+------+-----+---------+-------+

| Field  | Type        | Null | Key | Default | Extra |

+--------+-------------+------+-----+---------+-------+

| id     | varchar(64) | NO   | PRI | NULL    |       |

| name   | varchar(64) | NO   |     | NULL    |       |

| status | int(11)     | NO   |     | NULL    |       |

+--------+-------------+------+-----+---------+-------+

3 rows in set (0.00 sec)

 

mysql> insert into t_person ( id,name,status) values(zhangsan,zhang san,0);

Query OK, 1 row affected (0.08 sec)

 

mysql> insert into t_person ( id,name,status) values(lisi,li si,0);

Query OK, 1 row affected (0.05 sec)

 

mysql> select * from t_person;

+----------+-----------+--------+

| id       | name      | status |

+----------+-----------+--------+

| lisi     | li si     |      0 |

| zhangsan | zhang san |      0 |

+----------+-----------+--------+

2 rows in set (0.00 sec)

 

MyBatis应用开发(1)应用之开发环境