Code Monkey home page Code Monkey logo

generateentity's Introduction

GenerateEntity

将mysql数据库中表生成实体类

使用

没有将此功能单独写一个项目 , 可以将InitEntity类复制到自己项目中(确保有mysql驱动) ,直接运行main方法就行

特性

  • 支持配置配置包名
  • 支持配置忽略的表前缀
  • 支持配置类的创建人(类上的注释)
  • 支持配置创建时间(默认为当前时间)
  • 支持配置是否生成全参+无参构造
  • 支持配置将类根据关键字归类到不同包中
  • 支持配置属性名和Getter/Setter 采用驼峰命名法(字段包含下划线)

示例

表结构为:

CREATE TABLE `news` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(255) NOT NULL COMMENT '标题',
  `intro` varchar(255) NOT NULL COMMENT '说明(简介)',
  `content` text NOT NULL COMMENT '具体内容(富文本格式)',
  `createTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
  `url` varchar(255) NOT NULL COMMENT '外链的URL',
  `status` tinyint(1) NOT NULL COMMENT '状态 1显示   2不显示',
  `seq` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='新闻资讯表';

包名为:

me.lyinlong.test

生成的java实体类为:(注释都是表结构中的)

package me.lyinlong.test;

import java.sql.Timestamp;

/**
 * 新闻资讯表
 * Created by eightpigs on 2016-11-19
 */
public class News {

	private Integer id;

	/**
	 * 标题
	 */
	private String title;

	/**
	 * 说明(简介)
	 */
	private String intro;

	/**
	 * 具体内容(富文本格式)
	 */
	private String content;

	/**
	 * 创建时间
	 */
	private Timestamp createTime;

	/**
	 * 外链的URL
	 */
	private String url;

	/**
	 * 状态 1显示   2不显示
	 */
	private Integer status;

	private Integer seq;

	public News() { }

	public News(Integer id,String title,String intro,String content,Timestamp createTime,String url,Integer status,Integer seq) {
		this.id = id;
		this.title = title;
		this.intro = intro;
		this.content = content;
		this.createTime = createTime;
		this.url = url;
		this.status = status;
		this.seq = seq;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getIntro() {
		return intro;
	}

	public void setIntro(String intro) {
		this.intro = intro;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public Timestamp getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Timestamp createTime) {
		this.createTime = createTime;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public Integer getSeq() {
		return seq;
	}

	public void setSeq(Integer seq) {
		this.seq = seq;
	}

}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.