Java JPADatabase不工作的jooq codegen
我在JPADatabase中使用jooq codegen时遇到问题。我已经经历了这些,并做出了相应的改变。我的项目包含子模块,实体类位于域模块中。我有一个商务模块,它依赖于域。所以我在biz模块的pom.xml中有这个构建配置Java JPADatabase不工作的jooq codegen,java,maven,jpa,jooq,Java,Maven,Jpa,Jooq,我在JPADatabase中使用jooq codegen时遇到问题。我已经经历了这些,并做出了相应的改变。我的项目包含子模块,实体类位于域模块中。我有一个商务模块,它依赖于域。所以我在biz模块的pom.xml中有这个构建配置 <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.jooq</groupId>
<artifactId>jooq-codegen-maven</artifactId>
<version>3.9.1</version>
<!-- The plugin should hook into the generate goal -->
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq-meta-extensions</artifactId>
<version>3.9.1</version>
</dependency>
</dependencies>
<configuration>
<!-- Generator parameters -->
<generator>
<database>
<name>org.jooq.util.jpa.JPADatabase</name>
<properties>
<!-- A comma separated list of Java packages, that contain your entities -->
<property>
<key>packages</key>
<value>com.yaswanth.domain.entity</value>
</property>
</properties>
</database>
<target>
<packageName>com.yaswanth.domain.entity.jooq</packageName>
<directory>target/generated-sources/jooq</directory>
</target>
</generator>
</configuration>
</plugin>
</plugins>
</build>
域模块类已经生成,但插件仍然显示ClassNotFoundException。我使用的是jooq版本3.9.1。谁能告诉我我做错了什么
更新:卢卡斯·埃德尔的答案是正确的,并被接受。我自己对这个问题的回答对我有用,因为我在maven repo中缓存了这个特定的版本。我的答案是错误的。您似乎遇到了问题,该问题已在jOOQ 3.10中修复,并计划在3.9.3和3.8.8中解决
现在最好的解决方法可能是使用jooq meta extensions依赖项的GitHub版本(3.10-SNAPSHOT),或者相应地修补您的版本。根据@Lukas Eder的回答,我尝试了来自的建议。以下构建配置可以工作
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.jooq</groupId>
<artifactId>jooq-codegen-maven</artifactId>
<version>3.9.1</version>
<!-- The plugin should hook into the generate goal -->
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq-meta-extensions</artifactId>
<version>3.9.1</version>
</dependency>
<!--
This needs to be the dependency where the entity classes reside.
In my case, it is in the same module as the build profile is present.
Hence the version is ${project.version}
-->
<dependency>
<groupId>com.yaswanth</groupId>
<artifactId>domain</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<configuration>
<!-- Generator parameters -->
<generator>
<database>
<name>org.jooq.util.jpa.JPADatabase</name>
<properties>
<!-- A comma separated list of Java packages, that contain your entities -->
<property>
<key>packages</key>
<value>com.yaswanth.domain.entity</value>
</property>
</properties>
</database>
<target>
<packageName>com.yaswanth.domain.entity.jooq</packageName>
<directory>target/generated-sources/jooq</directory>
</target>
</generator>
</configuration>
</plugin>
</plugins>
org.apache.maven.plugins
maven编译器插件
1.8
1.8
org.jooq
jooq codegen maven
3.9.1
生成源
生成
org.jooq
jooq元扩展
3.9.1
com.yaswanth
领域
${project.version}
org.jooq.util.jpa.JPADatabase
包装
com.yaswanth.domain.entity
com.yaswanth.domain.entity.jooq
目标/生成源/jooq
这种配置的奇怪之处在于,我将模块作为依赖项包含在它自己的POM的构建概要中的插件中 您是否将实体放在使用jOOQ代码生成器的模块的依赖项中?见:是的。域模块是发生代码生成的biz模块中的一个依赖项。如果我降级到3.8.0会有帮助吗?@yaswanth:不会,为什么?这不是倒退。自从第一次实现以来,
JPADatabase
就一直存在这个问题。我认为类加载器问题是在以后的版本中开始出现的一个错误。@yaswanth:Hmm,不确定-最近才有报道。我怀疑,旧版本也会受到影响,但这还没有经过测试。我只是好奇。无论如何,我为这个问题写的另一个答案是有效的。你认为现在这是一个更好的解决方案吗?我的意思是问这会不会有副作用。
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.jooq</groupId>
<artifactId>jooq-codegen-maven</artifactId>
<version>3.9.1</version>
<!-- The plugin should hook into the generate goal -->
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq-meta-extensions</artifactId>
<version>3.9.1</version>
</dependency>
<!--
This needs to be the dependency where the entity classes reside.
In my case, it is in the same module as the build profile is present.
Hence the version is ${project.version}
-->
<dependency>
<groupId>com.yaswanth</groupId>
<artifactId>domain</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<configuration>
<!-- Generator parameters -->
<generator>
<database>
<name>org.jooq.util.jpa.JPADatabase</name>
<properties>
<!-- A comma separated list of Java packages, that contain your entities -->
<property>
<key>packages</key>
<value>com.yaswanth.domain.entity</value>
</property>
</properties>
</database>
<target>
<packageName>com.yaswanth.domain.entity.jooq</packageName>
<directory>target/generated-sources/jooq</directory>
</target>
</generator>
</configuration>
</plugin>
</plugins>