如何修复jOOQ代码生成工具错误?

我正在使用Spring Boot 2.1.1和jOOQ codegen工具3.11.7。我有一个Java类配置为稍微修改从pom中的MySQL表名派生的类名.xml:


<generator>

  <target>

    <packageName>com.example.foglight.db</packageName>

    <directory>src/main/java</directory>

  </target>

  <database>

    <excludes>

      flyway_schema_history

      | information_schema.*

    </excludes>

    <inputSchema>${dbName}</inputSchema>

    <outputSchemaToDefault>true</outputSchemaToDefault>

    <forcedTypes>

      <forcedType>

        <userType>java.util.UUID</userType>

        <binding>com.example.foglight.config.db.MysqlUuidBinding</binding>

        <types>BINARY\(16\)</types>

      </forcedType>

    </forcedTypes>

  </database>

  <generate>

    <deprecationOnUnknownTypes>false</deprecationOnUnknownTypes>

    <pojos>true</pojos>

  </generate>

  <!-- The default code generator. You can override this one, to generate your own code style

        Defaults to org.jooq.codegen.JavaGenerator -->

  <name>org.jooq.codegen.JavaGenerator</name>

  <!-- The naming strategy used for class and field names.

        You may override this with your custom naming strategy. Some examples follow

        Defaults to org.jooq.codegen.DefaultGeneratorStrategy -->

  <strategy>

 <name>com.example.foglight.config.db.DatabaseModelNamingStrategy</name>

  </strategy>

</generator>

当我从IntelliJ构建/运行应用程序时,一切正常,但是当我在相同的环境中运行或从命令行运行时,我收到以下错误:mvn generate-sourcesmvn install


[ERROR] Failed to execute goal org.jooq:jooq-codegen-maven:3.11.7:generate (default) on project foglight: Error running jOOQ code generation tool: com.example.foglight.config.db.DatabaseModelNamingStrategy -> [Help 1]

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.jooq:jooq-codegen-maven:3.11.7:generate (default) on project foglight: Error running jOOQ code generation tool

该类就在那里(否则IntelliJ也会抛出错误)。IDE在引擎盖下还做了什么使它工作吗?


largeQ
浏览 193回答 2
2回答

芜湖不芜

您可以按照 Lukas Eder 的建议编译该类并将其放在类路径上。为此,使用 maven-compiler-plugin 引入另一个执行,并将其绑定到生成源阶段:&nbsp; &nbsp; &nbsp; <plugin>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<groupId>org.apache.maven.plugins</groupId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<artifactId>maven-compiler-plugin</artifactId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<version>3.8.1</version>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<executions>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<execution>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <phase>generate-sources</phase>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <goals>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <goal>compile</goal>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </goals>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<configuration>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <source>1.8</source>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <target>1.8</target>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <includes>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<include>tb/database/jooq/custom/namingstrategies/*.java</include>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </includes>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</configuration>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</execution>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</executions>&nbsp; &nbsp; &nbsp; </plugin>

扬帆大鱼

jOOQ 代码生成器必须能够通过类路径访问生成器策略,这意味着在运行代码生成器之前,它必须已经过编译。由于代码生成器通常在包含它的 Maven 模块的编译阶段之前运行,因此您必须将生成器策略提取到另一个模块中,以确保它之前已编译。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java