jOOQ禁用DAO和POJO生成

时间:2014-10-03 08:38:59

标签: 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。我不知道这会如何影响这些变化。

1 个答案:

答案 0 :(得分:2)

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

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

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