代码之家  ›  专栏  ›  技术社区  ›  James Hiew

调试“jooq代码生成工具配置不正确”

  •  5
  • James Hiew  · 技术社区  · 6 年前

    我正在努力学习JooQ教程。我现在在 step 3(a>(code generation)but want to do the code generation step using maven.

    以下是my pom.xml的内容

    <?xml version=“1.0”encoding=“utf-8”?gt;
    <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/xsd/maven-4.0.0.xsd”>
    <modelversion>4.0.0</modelversion>
    
    <groupid>net.hiew</groupid>
    <artifactid>jooq教程</artifactid>
    <version>1.0-快照</version>
    
    <相关性>
    <相关性>
    <groupid>组织.jooq</groupid>
    <artifactid>jooq</artifactid>
    <版本>3.11.2</version>
    </dependency>
    <相关性>
    <groupid>组织.jooq</groupid>
    <artifactid>jooq meta</artifactid>
    <版本>3.11.2</version>
    </dependency>
    <相关性>
    <groupid>组织.jooq</groupid>
    <artifactid>jooq codegen</artifactid>
    <版本>3.11.2</version>
    </dependency>
    <相关性>
    <groupid>org.mariadb.jdbc</groupid>
    MiRADB Java客户端& lt;/AutoFrutd & Gt;
    <版本>1.1.7</version>
    </dependency>
    </dependencies>
    
    <构建>
    <插件>
    <插件>
    和LT;!--指定maven代码生成器插件-->
    和LT;!--对开源版本使用org.jooq
    商业版的org.joq.pro,
    Office Jooq.PRO-JAVA-6,支持Java 6的商业版本,
    org.jooq.trial免费试用版
    
    注意:只有开源版本托管在Maven Central上。
    从您的分发中手动导入其他内容-->
    <groupid>组织.jooq</groupid>
    <artifactid>jooq codegen maven</artifactid>
    <版本>3.11.2</version>
    
    <执行>
    <执行>
    
    
    
    
    
    
    
    
    
    
    
    

    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/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
    
        <groupId>net.hiew</groupId>
        <artifactId>jooq-tutorial</artifactId>
        <version>1.0-SNAPSHOT</version>
    
        <dependencies>
            <dependency>
                <groupId>org.jooq</groupId>
                <artifactId>jooq</artifactId>
                <version>3.11.2</version>
            </dependency>
            <dependency>
                <groupId>org.jooq</groupId>
                <artifactId>jooq-meta</artifactId>
                <version>3.11.2</version>
            </dependency>
            <dependency>
                <groupId>org.jooq</groupId>
                <artifactId>jooq-codegen</artifactId>
                <version>3.11.2</version>
            </dependency>
            <dependency>
                <groupId>org.mariadb.jdbc</groupId>
                <artifactId>mariadb-java-client</artifactId>
                <version>1.1.7</version>
            </dependency>
        </dependencies>
    
        <build>
            <plugins>
                <plugin>
                    <!-- Specify the maven code generator plugin -->
                    <!-- Use org.jooq            for the Open Source Edition
                             org.jooq.pro        for commercial editions,
                             org.jooq.pro-java-6 for commercial editions with Java 6 support,
                             org.jooq.trial      for the free trial edition
    
                         Note: Only the Open Source Edition is hosted on Maven Central.
                               Import the others manually from your distribution -->
                    <groupId>org.jooq</groupId>
                    <artifactId>jooq-codegen-maven</artifactId>
                    <version>3.11.2</version>
    
                    <executions>
                        <execution>
                            <id>jooq-codegen</id>
                            <phase>generate-sources</phase>
                            <goals>
                                <goal>generate</goal>
                            </goals>
                            <configuration>
                                <!-- Configure the database connection here -->
                                <jdbc>
                                    <driver>org.mariadb.jdbc.Driver</driver>
                                    <url>jdbc:mariadb://localhost:3306/library</url>
                                    <user>root</user>
                                    <password>mysql</password>
                                </jdbc>
    
                                <generator>
                                    <!-- The default code generator. You can override this one, to generate your own code style.
                                         Supported generators:
                                         - org.jooq.codegen.JavaGenerator
                                         - org.jooq.codegen.ScalaGenerator
                                         Defaults to org.jooq.codegen.JavaGenerator -->
                                    <name>org.jooq.codegen.JavaGenerator</name>
    
                                    <database>
                                        <!-- The database type. The format here is:
                                             org.util.[database].[database]Database -->
                                        <name>org.jooq.meta.mariadb.MariaDBDatabase</name>
    
                                        <!-- The database schema (or in the absence of schema support, in your RDBMS this
                                             can be the owner, user, database name) to be generated -->
                                        <inputSchema>library</inputSchema>
    
                                        <!-- All elements that are generated from your schema
                                             (A Java regular expression. Use the pipe to separate several expressions)
                                             Watch out for case-sensitivity. Depending on your database, this might be important! -->
                                        <includes>.*</includes>
    
                                        <!-- All elements that are excluded from your schema
                                             (A Java regular expression. Use the pipe to separate several expressions).
                                             Excludes match before includes, i.e. excludes have a higher priority -->
                                        <excludes></excludes>
                                    </database>
    
                                    <target>
                                        <!-- The destination package of your generated classes (within the destination directory) -->
                                        <packageName>net.hiew.jooqtutorial.generated</packageName>
    
                                        <!-- The destination directory of your generated classes. Using Maven directory layout here -->
                                        <directory>/home/james/src/local/jooqtutorial/src/main/java/</directory>
                                    </target>
                                </generator>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </project>
    

    project directory

    mvn -e jooq-codegen:generate

    [INFO] --- jooq-codegen-maven:3.11.2:generate (default-cli) @ jooq-tutorial ---                                                                                                                              
    [ERROR] Incorrect configuration of jOOQ code generation tool                                                                                                                                                 
    [ERROR]                                                                                                                                                                                                      
    The jOOQ-codegen-maven module's generator configuration is not set up correctly.                                                                                                                             
    This can have a variety of reasons, among which:                                                                                                                                                             
    - Your pom.xml's <configuration> contains invalid XML according to jooq-codegen-3.11.0.xsd                                                                                                                   
    - There is a version or artifact mismatch between your pom.xml and your commandline
    

    <configuration>

    2 回复  |  直到 6 年前
        1
  •  4
  •   wallek876    6 年前

    <plugin>
      ...
      <executions>
         ...
      </executions>
    
      <configuration>
         ...
      </configuration>
      ...
    </plugin>
    

    <plugin>
      <!-- Specify the maven code generator plugin -->
      <!-- Use org.jooq            for the Open Source Edition             org.jooq.pro        for commercial editions,             org.jooq.pro-java-6 for commercial editions with Java 6 support,             org.jooq.trial      for the free trial edition         Note: Only the Open Source Edition is hosted on Maven Central.               Import the others manually from your distribution -->
      <groupId>org.jooq</groupId>
      <artifactId>jooq-codegen-maven</artifactId>
      <version>3.11.2</version>
    
      <executions>
        <execution>
          <id>jooq-codegen</id>
          <phase>generate-sources</phase>
          <goals>
            <goal>generate</goal>
          </goals>
        </execution>
      </executions>
    
      <dependencies>
        <dependency>
          <groupId>org.mariadb.jdbc</groupId>
          <artifactId>mariadb-java-client</artifactId>
          <version>${mariadb.version}</version>
        </dependency>
      </dependencies>
    
      <configuration>
        <!-- Configure the database connection here -->
        <jdbc>
          <driver>org.mariadb.jdbc.Driver</driver>
          <url>jdbc:mariadb://localhost:3306/library</url>
          <user>root</user>
          <password>mysql</password>
        </jdbc>
    
        <generator>
          <!-- The default code generator. You can override this one, to generate your own code style.                     Supported generators:                     - org.jooq.codegen.JavaGenerator                     - org.jooq.codegen.ScalaGenerator                     Defaults to org.jooq.codegen.JavaGenerator -->
          <name>org.jooq.codegen.JavaGenerator</name>
          <database>
            <!-- The database type. The format here is:                         org.util.[database].[database]Database -->
            <name>org.jooq.meta.mariadb.MariaDBDatabase</name>
            <!-- The database schema (or in the absence of schema support, in your RDBMS this                         can be the owner, user, database name) to be generated -->
            <inputSchema>library</inputSchema>
            <!-- All elements that are generated from your schema                         (A Java regular expression. Use the pipe to separate several expressions)                         Watch out for case-sensitivity. Depending on your database, this might be important! -->
            <includes>.*</includes>
            <!-- All elements that are excluded from your schema                         (A Java regular expression. Use the pipe to separate several expressions).                         Excludes match before includes, i.e. excludes have a higher priority -->
            <excludes>
            </excludes>
          </database>
          <target>
            <!-- The destination package of your generated classes (within the destination directory) -->
            <packageName>net.hiew.jooqtutorial.generated</packageName>
            <!-- The destination directory of your generated classes. Using Maven directory layout here -->
            <directory>/home/james/src/local/jooqtutorial/src/main/java/</directory>
          </target>
        </generator>
    
      </configuration>
    
    </plugin>
    

        2
  •  2
  •   Lukas Eder    6 年前

    wallek876's answer default-cli as documented here

    <executions>
        <execution>
            <id>default-cli</id>
            <phase>generate-sources</phase>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <!-- Configure the database connection here -->
                <jdbc>
                ...
    

    <profiles>
        <profile>
            <id>jooq-codegen</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.jooq</groupId>
                        <artifactId>jooq-codegen-maven</artifactId>
                        <version>3.11.2</version>
                        ...
    

    mvn install -P jooq-codegen