1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/fluent-mybatis-fluent-mybatis-docs

Клонировать/Скачать
README.md 1.1 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
darui.wu Отправлено 18.08.2021 17:58 0181684

使用fluent mybatis生成Entity文件

增加生成代码的jar包依赖

<dependency>
    <groupId>com.github.atool</groupId>
    <artifactId>fluent-mybatis-processor</artifactId>
    <version>${fluent.mybatis.version}</version>
    <scope>provided</scope>
</dependency>

使用注解定义方式

public class EntityGeneratorDemo {
    public static final String url = "jdbc:mysql://localhost:3306/fluent_mybatis?useUnicode=true&characterEncoding=utf8";

    public static void main(String[] args) throws Exception {
        FileGenerator.build(Empty.class);
    }

    @Tables(
        // 设置数据库连接信息
        url = url, username = "root", password = "password",
        // 设置entity类生成src目录, 相对于 user.dir
        srcDir = "src/main/java",
        // 设置entity类的package值
        basePack = "cn.org.atool.fluent.mybatis.demo3",
        // 设置dao接口和实现的src目录, 相对于 user.dir
        daoDir = "src/main/java",
        // 设置哪些表要生成Entity文件
        tables = {@Table(value = {"hello_world"})}
    )
    static class Empty {
    }
}

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/fluent-mybatis-fluent-mybatis-docs.git
git@api.gitlife.ru:oschina-mirror/fluent-mybatis-fluent-mybatis-docs.git
oschina-mirror
fluent-mybatis-fluent-mybatis-docs
fluent-mybatis-fluent-mybatis-docs
master