spring-boot集成beetlsql

1、注入依赖

            com.ibeetl

            beetl

            2.5.0

        

 

        

            com.ibeetl

            beetlsql

            2.6.4

        


2、在application.yml中添加配置

spring:

  datasource:

    beetlsql:

      dbStyle: org.beetl.sql.core.db.MySqlStyle

      sqlRoot: /sql

      debug: 1

debug为1时,显示执行sql,0则不显示。
3、使用
首先,在类中注入SQLManager,调用他的方法执行数据库

@Autowired

private SQLManager splManager;

声明一个sql存放的对象

SQLReady sqlReady=new SQLReady("sql语句");

若是查询,则有返回值:

List list=sqlManager.execute(sqlReady,T.class);

若是执行持久化,则是

sqlManager.executeUpdate(sqlReady);

4、实体类书写

import org.beetl.sql.core.annotatoin.Table;

 

import java.util.Date;

 

/**

 * Created by 赵亚辉 on 2017/8/16.

 */

@Table(name="zj_chapter_edit")

public class Chapter extends org.beetl.sql.core.TailBean{

 

    private String id;

 

    private String name;

 

    private String nianji;

 

    private String xd;

 

    private String child;

 

    private Integer type;

 

    private Integer isLast=0;

 

    private String pid;

 

    private Date createDate=new Date();

 

    private String categories;

 

    private String fullIds;

 

    public String getFullIds() {

        return fullIds;

    }

 

    public void setFullIds(String fullIds) {

        this.fullIds = fullIds;

    }

 

    public String getId() {

        return id;

    }

 

    public void setId(String id) {

        this.id = id;

    }

 

    public String getName() {

        return name;

    }

 

    public void setName(String name) {

        this.name = name;

    }

 

    public String getNianji() {

        return nianji;

    }

 

    public void setNianji(String nianji) {

        this.nianji = nianji;

    }

 

    public String getXd() {

        return xd;

    }

 

    public void setXd(String xd) {

        this.xd = xd;

    }

 

    public String getChild() {

        return child;

    }

 

    public void setChild(String child) {

        this.child = child;

    }

 

    public Integer getType() {

        return type;

    }

 

    public void setType(Integer type) {

        this.type = type;

    }

 

    public Integer getIsLast() {

        return isLast;

    }

 

    public void setIsLast(Integer isLast) {

        this.isLast = isLast;

    }

 

    public String getPid() {

        return pid;

    }

 

    public void setPid(String pid) {

        this.pid = pid;

    }

 

    public Date getCreateDate() {

        return createDate;

    }

 

    public void setCreateDate(Date createDate) {

        this.createDate = createDate;

    }

 

    public String getCategories() {

        return categories;

    }

 

    public void setCategories(String categories) {

        this.categories = categories;

    }

}

你可能感兴趣的:(spring-boot集成beetlsql)