JOOQ 为table和view自动生成代码
来源:互联网 发布:网络打印适配器 编辑:程序博客网 时间:2024/04/29 21:49
JOOQ是一个Java的ORM框架,提供了基本的SQL构建、执行等功能,并且使用了链式的API,代码整洁易懂。JOOQ也提供了代码自动生成的功能,也就是根据数据库中的表或者视图生成相应的Java Bean,具体如下,在maven里面添加一个plugin:
<plugin> <groupId>org.jooq</groupId> <artifactId>jooq-codegen-maven</artifactId> <version>3.9.2</version> <executions> <execution> <phase>generate-sources</phase> <goals> <goal>generate</goal> </goals> </execution> </executions> <dependencies> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.38</version> </dependency> </dependencies> <configuration> <jdbc> <driver>com.mysql.jdbc.Driver</driver> <url>${spring.datasource.url}</url> <username>${spring.datasource.username}</username> <password>${spring.datasource.password}</password> </jdbc> <generator> <database> <!--下面这两行是为view也生成代码的关键--> <!--force generating id'sfor everything in public schema, that has an 'id' field--> <syntheticPrimaryKeys>public\..*\.id</syntheticPrimaryKeys> <!--name for fake primary key--> <overridePrimaryKeys>override_primmary_key</overridePrimaryKeys> <name>org.jooq.util.mysql.MySQLDatabase</name> <!--include和exclude用于控制为数据库中哪些表生成代码--> <includes>.*</includes> <!--<excludes></excludes>--> <!--数据库名称--> <inputSchema>xxxxxx</inputSchema> </database> <generate> <!--生成dao和pojo--> <daos>true</daos> <pojos>true</pojos> <!--把数据库时间类型映射到java 8时间类型--> <javaTimeTypes>true</javaTimeTypes> <!--<interfaces>true</interfaces>--> <!--不在生成的代码中添加spring注释,比如@Repository--> <springAnnotations>false</springAnnotations> </generate> <target> <!--生成代码文件的包名及放置目录--> <packageName>com.iot.xxxxx.jooq</packageName> <directory>src/main/java</directory> </target> </generator> </configuration> </plugin>
阅读全文
4 0
- JOOQ 为table和view自动生成代码
- JOOQ 学习笔记一:代码自动生成
- Jooq根据数据库表自动生成对数据库操作的Java代码教程及配置
- ADF中为Table自动生成行号
- 利用TextExpander自动为代码生成get和set方法
- android 布局 View初始化代码自动生成
- jooq使用自定义策略生成代码(How to use a custom strategy with the jOOQ code-generator and Maven?)
- 在ADF中为Table自动生成行号
- (2)通过脚手架自动生成controller和view ----代码先行/数据库先行
- 代码自动生成和抽象
- 代码自动生成和抽象
- 代码自动生成和抽象
- 代码自动生成和抽象
- PowerDesigner自动生成Table
- js自动生成table
- 生成Web服务器控件Table和生成HTMLTable的代码
- 【译】MVC3 20个秘方-(2)通过脚手架自动生成controller和view ----代码先行/数据库先行
- 干净的table view 代码
- STL----vector 用法
- 华为交换机常用命令
- Linux串口驱动程序(4)-串口发送分析
- H5 画面关闭软键盘
- Trafodion CQD-hbase_coprocessors
- JOOQ 为table和view自动生成代码
- MySQL查询补充 HTML简记 6.30
- java编译原理
- 异步上传文件或图片
- PHPstorm的相关配置
- 划分子网
- 循环与闭包 之 for循环经典问题解释 / 结合《你不知道的JS》与《高程》案例
- Linux命令--ls
- 反射:使用反射调用方法