为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

largeQ 2022-08-17 10:42:26
我正在使用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在引擎盖下还做了什么使它工作吗?
查看完整描述

2 回答

?
芜湖不芜

TA贡献1796条经验 获得超7个赞

您可以按照 Lukas Eder 的建议编译该类并将其放在类路径上。为此,使用 maven-compiler-plugin 引入另一个执行,并将其绑定到生成源阶段:


      <plugin>

         <groupId>org.apache.maven.plugins</groupId>

         <artifactId>maven-compiler-plugin</artifactId>

         <version>3.8.1</version>

         <executions>

         <execution>

              <phase>generate-sources</phase>

              <goals>

                <goal>compile</goal>

              </goals>

             <configuration>

                <source>1.8</source>

                <target>1.8</target>

                <includes>

                   <include>tb/database/jooq/custom/namingstrategies/*.java</include>

                </includes>

             </configuration>

         </execution>

         </executions>

      </plugin>


查看完整回答
反对 回复 2022-08-17
?
扬帆大鱼

TA贡献1799条经验 获得超9个赞

jOOQ 代码生成器必须能够通过类路径访问生成器策略,这意味着在运行代码生成器之前,它必须已经过编译。由于代码生成器通常在包含它的 Maven 模块的编译阶段之前运行,因此您必须将生成器策略提取到另一个模块中,以确保它之前已编译。


查看完整回答
反对 回复 2022-08-17
  • 2 回答
  • 0 关注
  • 149 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信