1:定义表
@Table
name :表名
desc:表啥意思 。
action:spring controller @RequestMapping("/user/")
@Table(name = "user_bean", desc = "需要采摘的信息",action="/user/")
public class UserBean extends BaseBean
2:定义列
@Column
name :列名
columnType:JDBCType ->mybatis jdbcType .
length :列的长度
desc :列的含义。
selectType:mybatis -> mapper.xml 查询类型 。
isCanNull:是否为空 ;
defaultValue :默认值
3:定义索引
@Index 该列是否是索引 ;
type: mysql 索引类型;
name: 索引名称
@Column(name = "name", columnType = ColumnType.VARCHAR, length = 20, desc = "姓名", defaultValue = "", selectType=SelectType.LIKE ,isCanNull=true)
@Index(name="name_index",type=Type.Default)
private String name;
4:定义主键
@Id 给列主键
@Column(name = "uuids", columnType = ColumnType.BIGINTLong, length = 20, desc = "ID",
defaultValue = "")
@Id 给列主键
private Long id;
//生成相关文件的java package ;基础包
String basePath="cn.saiot.module.demo";
IMyBatisBuildService iIMyBatisBuildService = new MyBatisBuildService(basePath);
DBUtils iDBUtils=new MariadbDBUtils("jdbc:mysql://192.188.0.5:3306/test", "root", "123456");
// UserBean-> pojos "D:\\mnt\\"-> 生成相关文件的基础目录
iIMyBatisBuildService.build(UserBean.class, "D:\\mnt\\",true,iDBUtils);
如果执行成功。
会在 D:\\mnt\\ 下 生成 相关的 java 代码
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-dbutils</groupId>
<artifactId>commons-dbutils</artifactId>
<version>1.6</version>
<scope>test</scope>
</dependency>