gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 09:47:36 25 4
gpt4 key购买 nike

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

<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 构建/运行应用程序时,一切正常,但是当我在同一环境中从命令行运行 mvngenerate-sourcesmvninstall 时,我收到以下错误:

[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

详细解释如下:

Caused by: java.lang.ClassNotFoundException: com.example.foglight.config.db.DatabaseModelNamingStrategy
at java.net.URLClassLoader.findClass (URLClassLoader.java:471)
at java.lang.ClassLoader.loadClass (ClassLoader.java:588)
at java.lang.ClassLoader.loadClass (ClassLoader.java:521)
at org.jooq.codegen.GenerationTool.loadClass (GenerationTool.java:819)
at org.jooq.codegen.GenerationTool.run (GenerationTool.java:352)
at org.jooq.codegen.GenerationTool.generate (GenerationTool.java:220)
at org.jooq.codegen.maven.Plugin.execute (Plugin.java:197)

该类就在那里(否则 IntelliJ 也会抛出错误)。 IDE 在幕后还做了什么其他事情来使其正常工作吗?

最佳答案

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

      <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>

关于java - 如何修复jOOQ代码生成工具错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55222589/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com