springboot集成jooq(一)

背景:基于上篇springboot整合flyway进行

一、pom.xml添加jooq相关依赖

<properties>
        <jooq.version>3.12.2</jooq.version>
    </properties>
<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jooq</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jooq</groupId>
            <artifactId>jooq-meta</artifactId>
            <version>${jooq.version}</version>
        </dependency>
        <dependency>
            <groupId>org.jooq</groupId>
            <artifactId>jooq-codegen</artifactId>
            <version>${jooq.version}</version>
        </dependency>

二、pom.xml增加jooq插件配置

<!-- 用于加载application.yml信息,在pom文件可读取到application.yml中信息 -->
            <plugin>
                <groupId>it.ozimov</groupId>
                <artifactId>yaml-properties-maven-plugin</artifactId>
                <version>1.1.3</version>
                <executions>
                    <execution>
                        <phase>initialize</phase>
                        <goals>
                            <goal>read-project-properties</goal>
                        </goals>
                        <configuration>
                            <files>
                                <file>src/main/resources/application.yml</file>
                            </files>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- jooq的插件配置 -->
            <plugin>
                <groupId>org.jooq</groupId>
                <artifactId>jooq-codegen-maven</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <jdbc>
                        <url>${spring.datasource.url}</url>
                        <user>${spring.datasource.username}</user>
                        <password>${spring.datasource.password}</password>
                        <driver>${spring.datasource.driver-class-name}</driver>
                    </jdbc>
                    <generator>
                        <!-- 代码生成器 -->
                        <name>org.jooq.codegen.JavaGenerator</name>
                        <database>
                            <name>org.jooq.meta.postgres.PostgresDatabase</name>
                            <!--include和exclude用于控制为数据库中哪些表生成代码-->
                            <includes>.*</includes>
                            <excludes />
                            <!--schema名称-->
                            <inputSchema>myschema</inputSchema>
                        </database>
                        <target>
                            <!--生成代码文件的包名及放置目录-->
                            <packageName>com.zsx.generator.jooq</packageName>
                            <directory>src/main/java</directory>
                        </target>
                    </generator>
                </configuration>
            </plugin>

 

三、application增加jooq方言配置

spring:
  jooq:
    sql-dialect: POSTGRES

四、执行mvn compile命令

H:\JDK\jdk-13.0.1\bin\java.exe -Dmaven.multiModuleProjectDirectory=F:\IdeaProjects\myspringboottemplate -Dmaven.home=H:\Maven\apache-maven-3.6.2 -Dclassworlds.conf=H:\Maven\apache-maven-3.6.2\bin\m2.conf "-Dmaven.ext.class.path=H:\JetBrains\IntelliJ IDEA 2019.1.3\plugins\maven\lib\maven-event-listener.jar" -Dfile.encoding=UTF-8 -classpath H:\Maven\apache-maven-3.6.2\boot\plexus-classworlds-2.6.0.jar org.codehaus.classworlds.Launcher -Didea.version2019.2.4 -s H:\Maven\apache-maven-3.6.2\conf\settings.xml compile
[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for com.zsx:my-springboot-template:jar:1.0-SNAPSHOT
[WARNING] 'dependencies.dependency.scope' for org.springframework.boot:spring-boot-devtools:jar must be one of [provided, compile, runtime, test, system] but is 'true'. @ line 122, column 20
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
[INFO] 
[INFO] -------------------< com.zsx:my-springboot-template >-------------------
[INFO] Building my-springboot-template 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- yaml-properties-maven-plugin:1.1.3:read-project-properties (default) @ my-springboot-template ---
Downloading from aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/yaml/snakeyaml/1.16/snakeyaml-1.16.pom
Downloaded from aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/yaml/snakeyaml/1.16/snakeyaml-1.16.pom (0 B at 0 B/s)
Downloading from aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/yaml/snakeyaml/1.16/snakeyaml-1.16.jar
Downloading from aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/codehaus/plexus/plexus-utils/3.0.22/plexus-utils-3.0.22.jar
Downloaded from aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/codehaus/plexus/plexus-utils/3.0.22/plexus-utils-3.0.22.jar (0 B at 0 B/s)
Downloaded from aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/yaml/snakeyaml/1.16/snakeyaml-1.16.jar (0 B at 0 B/s)
[INFO] 
[INFO] --- jooq-codegen-maven:3.12.2:generate (default) @ my-springboot-template ---
[INFO] No <inputCatalog/> was provided. Generating ALL available catalogs instead.
[INFO] License parameters       
[INFO] ----------------------------------------------------------
[INFO]   Thank you for using jOOQ and jOOQ's code generator
[INFO]                          
[INFO] Database parameters      
[INFO] ----------------------------------------------------------
[INFO]   dialect                : POSTGRES
[INFO]   URL                    : jdbc:postgresql://127.0.0.1:5432/mydb10
[INFO]   target dir             : F:\IdeaProjects\myspringboottemplate\src\main\java
[INFO]   target package         : com.zsx.generator.jooq
[INFO]   includes               : [.*]
[INFO]   excludes               : []
[INFO]   includeExcludeColumns  : false
[INFO] ----------------------------------
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值