首页 JOOQ_中文教程(七)

JOOQ_中文教程(七)

举报
开通vip

JOOQ_中文教程(七) The jOOQ User Manual 2.1. 2.1。 Configuration and setup of the generator jOOQ is brought to you by Lukas Eder. Distributed under the Apache 2 licence Page 24 / 76 - - The property file - - jooq.jar, jooq-meta.jar, jooq-codegen.jar - - The JDB...

JOOQ_中文教程(七)
The jOOQ User Manual 2.1. 2.1。 Configuration and setup of the generator jOOQ is brought to you by Lukas Eder. Distributed under the Apache 2 licence Page 24 / 76 - - The property file - - jooq.jar, jooq-meta.jar, jooq-codegen.jar - - The JDBC driver you configured A command-line example (For Windows, unix/linux/etc will be similar) - - Put the property file, jooq*.jar and the JDBC driver into a directory, eg C:\temp\jooq - - Go to C:\temp\jooq - - Run java -cp jooq.jar;jooq-meta.jar;jooq-codegen.jar;[JDBC-driver].jar;. org.jooq.util.GenerationTool /[property file] Note that the property file must be passed as a classpath resource Run code generation from Eclipse Of course, you can also run code generation from your IDE. In Eclipse, set up a project like this. Note that 请注意 this example uses jOOQ's log4j support by adding log4j.xml and log4j.jar to the project classpath: Once the project is set up correctly with all required artefacts on the classpath, you can configure an Eclipse Run Configuration for org.jooq.util.GenerationTool. Page 25 第25页 The jOOQ User Manual 2.1. 2.1。 Configuration and setup of the generator jOOQ is brought to you by Lukas Eder. Distributed under the Apache 2 licence Page 25 / 76 With the properties file as an argument And the classpath set up correctly Page 26 第26页 The jOOQ User Manual 2.1. 2.1。 Configuration and setup of the generator jOOQ is brought to you by Lukas Eder. Distributed under the Apache 2 licence Page 26 / 76 Finally, run the code generation and see your generated artefacts Run generation with ant You can also use an ant task to generate your classes. As a rule of thumb, remove the dots "." and dashes "-" from the .properties file's property names to get the ant task's arguments: Page 27 第27页 The jOOQ User Manual 2.1. 2.1。 Configuration and setup of the generator jOOQ is brought to you by Lukas Eder. Distributed under the Apache 2 licence Page 27 / 76 Note that when running code generation with ant's task, you may have to set fork="true": [...] [...] Integrate generation with Maven Using the official jOOQ-codegen-maven plugin, you can integrate source code generation in your Maven build process: Page 28 第28页 The jOOQ User Manual 2.1. 2.1。 Configuration and setup of the generator jOOQ is brought to you by Lukas Eder. Distributed under the Apache 2 licence Page 28 / 76 org.jooq jooq-codegen-maven 1.6.7 generate postgresql postgresql 8.4-702.jdbc4 org.postgresql.Driver jdbc:postgresql:postgres postgres test org.jooq.util.DefaultGenerator org.jooq.util.postgres.PostgresDatabase .* public true false org.jooq.util.maven.example target/generated-sources/jooq See the full example of a pom.xml including the jOOQ-codegen artefact here: https://github.com/ lukaseder/jOOQ/blob/master/jOOQ-codegen-maven-example/pom.xml Migrate properties files from jOOQ 1.7, early versions of jOOQ 2.0.x: Before jOOQ 2.0.4, the code generator was configured using properties files These files are still supported for source code generation, but their syntax won't be maintained any longer. If you wish to 如果你想 migrate to XML, you can migrate the file using this command on the command line org.jooq.util.GenerationTool /jooq-config.properties migrate Using the migrate flag, jOOQ will read the properties file and output a corresponding XML file on system out 出 Use jOOQ generated classes in your application Be sure, both jOOQ.jar and your generated package (see configuration) are located on your classpath. Once this is done, you can execute SQL statements with your generated classes. Page 29 第29页 The jOOQ User Manual 2.2. 2.2。 Advanced generator configuration jOOQ is brought to you by Lukas Eder. Distributed under the Apache 2 licence Page 29 / 76 2.2. 2.2。 Advanced generator configuration Code generation In the previous section we have seen how jOOQ's source code generator is configured and run within a few steps. In this chapter we'll treat some advanced settings org.jooq.util.DefaultGenerator org.jooq.util.DefaultGeneratorStrategy The following example shows how you can override the DefaultGeneratorStrategy to render table and column names the way they are defined in the database, rather than switching them to camel case: Page 30 第30页 The jOOQ User Manual 2.2. 2.2。 Advanced generator configuration jOOQ is brought to you by Lukas Eder. Distributed under the Apache 2 licence Page 30 / 76 /** / ** * It is recommended that you extend the DefaultGeneratorStrategy. Most of the 大部分 * GeneratorStrategy API is already declared final. You only need to override any 找好工作,来深圳英才网:http://0755.job1001.com
本文档为【JOOQ_中文教程(七)】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_251459
暂无简介~
格式:doc
大小:57KB
软件:Word
页数:5
分类:互联网
上传时间:2012-06-07
浏览量:26