java - jOOQ 禁用 DAO 和 POJO 生成

标签 java gradle code-generation pojo jooq

我的项目需要我自己生成 DAO 和 POJO。必须对其进行一定的修改。我的 SRS 说我必须使用 jOOQ。我是第一次使用它;我知道 jOOQ 会自行生成 POJO 和 DAO,但我找不到禁用它的方法。

我在 jOOQ 的文档中找不到任何可以帮助我解决这个问题的内容。有人可以告诉我如何从 DAO 和 POJO 生成中禁用 jOOQ 但仍提供记录。

Maven pom.xml 文件如下:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
    <groupId>org.jooq</groupId>
    <artifactId>jooq-parent</artifactId>
    <version>3.4.1</version>
</parent>

<groupId>org.jooq</groupId>
<artifactId>jooq</artifactId>
<name>jOOQ</name>

<licenses>
    <license>
        <name>Apache License, Version 2.0</name>
        <url>http://www.jooq.org/inc/LICENSE.txt</url>
        <distribution>repo</distribution>
    </license>
    <!-- [pro] xxx
    xxxxxxxxx
        xxxxxxxxxx xxxxxxx xxx xxxxxxxxxxx xxxxxxxxxxxxxxxx
        xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    xxxxxxxxxx
    xxxx [/pro] -->
</licenses>

<build>
    <plugins>
        <!-- XJC-generate JAXB artefacts. Contribution is the courtesy
             of Sergey Epik -->
        <plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <version>0.8.1</version>
            <executions>
                <!-- If this causes trouble in your Eclipse m2e lifecycle configuration, try using
                     http://m2eclipse.sonatype.org/sites/m2e/, instead of the official m2e Eclipse
                     plugin
                  -->
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <extension>true</extension>
                <strict>false</strict>
                <schemaDirectory>src/main/resources/xsd</schemaDirectory>
                <bindingDirectory>src/main/resources/xjb</bindingDirectory>
                <schemaIncludes>
                    <include>jooq-runtime-3.3.0.xsd</include>
                </schemaIncludes>
                <generatePackage>org.jooq.conf</generatePackage>
                <args>
                    <arg>-Xxew</arg>
                    <arg>-Xxew:instantiate lazy</arg>
                    <arg>-Xxew:delete</arg>
                    <arg>-Xfluent-api</arg>
                    <arg>-Xdefault-value</arg>
                    <arg>-Xannotate</arg>
                    <arg>-Xinheritance</arg>
                </args>
                <plugins>
                    <plugin>
                        <groupId>com.github.jaxb-xew-plugin</groupId>
                        <artifactId>jaxb-xew-plugin</artifactId>
                        <version>1.0</version>
                   </plugin>
                    <plugin>
                        <groupId>org.jvnet.jaxb2_commons</groupId>
                        <artifactId>jaxb2-fluent-api</artifactId>
                        <version>3.0</version>
                    </plugin>
                    <plugin>
                        <groupId>org.jvnet.jaxb2_commons</groupId>
                        <artifactId>jaxb2-default-value</artifactId>
                        <version>1.1</version>
                    </plugin>
                    <plugin>
                        <groupId>org.jvnet.jaxb2_commons</groupId>
                        <artifactId>jaxb2-basics-annotate</artifactId>
                        <version>0.6.2</version>
                    </plugin>              
                    <plugin>
                        <groupId>org.jvnet.jaxb2_commons</groupId>
                        <artifactId>jaxb2-basics</artifactId>
                        <version>0.5.3</version>
                    </plugin>      
                </plugins>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <version>2.1.0</version>
            <extensions>true</extensions>
            <executions>
                <execution>
                    <id>bundle-manifest</id>
                    <phase>process-classes</phase>
                    <goals>
                        <goal>manifest</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <supportedProjectTypes>
                    <supportedProjectType>jar</supportedProjectType>
                </supportedProjectTypes>
                <instructions>
                    <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                    <Export-Package>*</Export-Package>
                    <Import-Package>
                        javax.persistence;resolution:=optional,
                        org.apache.log4j;resolution:=optional,
                        *
                    </Import-Package>
                    <_versionpolicy>[$(version;==;$(@)),$(version;+;$(@)))</_versionpolicy>
                </instructions>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <archive>
                    <!-- add the generated manifest to the jar -->
                    <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
                </archive>
            </configuration>
        </plugin>
    </plugins>
</build>

<profiles>
    <profile>
        <id>release</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-gpg-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>sign-artifacts</id>
                            <phase>verify</phase>
                            <goals>
                                <goal>sign</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

<dependencies>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.16</version>
        <type>jar</type>
        <scope>provided</scope>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>integration</artifactId>
        <version>1.6.1</version>
        <type>jar</type>
        <scope>provided</scope>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>javax.persistence</groupId>
        <artifactId>persistence-api</artifactId>
        <version>1.0</version>
        <type>jar</type>
        <scope>provided</scope>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
        <version>1.1.0.Alpha1</version>
        <type>jar</type>
        <scope>provided</scope>
        <optional>true</optional>
    </dependency>


    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.11</version>
        <type>jar</type>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.jmock</groupId>
        <artifactId>jmock-junit4</artifactId>
        <version>2.6.0</version>
        <type>jar</type>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.6.1</version>
        <type>jar</type>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>3.1</version>
        <type>jar</type>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.velocity</groupId>
        <artifactId>velocity</artifactId>
        <version>1.7</version>
        <type>jar</type>
        <scope>test</scope>
    </dependency>
</dependencies>

构建使用 gradle 。我也不知道这将如何影响这些变化。

最佳答案

该项目是使用 gradle 构建的。因此所有依赖项的配置都被重定向到 build.gradle 。 帮助我改变 jooq 属性的构建文件的摘录是:

    jooq 
    { 
      generator 
        { generate 
           { relations = true 
             deprecated = false 
             records = true 
             immutablePojos = false 
             daos = false 
             fluentSetters = true 
       } 
      target { packageName = '...' } 

该文件无法从项目目录访问,但我可以在这里编辑它!!

关于java - jOOQ 禁用 DAO 和 POJO 生成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26175812/

相关文章:

java - Spring 3 with Tiles 2.2 - 模板不显示

kotlin - 通过 IntelliJ 运行 Google App Engine Standard 时出错 - 找不到 appengine-web.xml

java - 安装com.google.android.gms :play-services:8. 4.4

c++ - 有没有好的C++模板引擎

java - 来自 Java(Jetty 下的 Spring MVC)应用程序的 ADFS 身份验证和模拟

java - 特定时间间隔之间的警报

java - 使用表中的长整数格式化单元格

java - Eclipse Gradle 项目未找到 JUnit 测试

php - 使用 PHP 生成/复制 HTML

haskell - 实现构建器模式以在 haskell 中生成测试用例