Luk*_*der 13 java code-generation maven jooq
使用jOOQ,我可能希望将jOOQ代码生成器与Maven和自定义生成器策略结合使用.看起来好像可以这样做(省略不相关的部分):
<plugin>
  <groupId>org.jooq</groupId>
  <artifactId>jooq-codegen-maven</artifactId>
  <version>2.2.2</version>
  <!-- The plugin should hook into the generate goal -->
  <executions>
    <execution>
      <goals>
        <goal>generate</goal>
      </goals>
    </execution>
  </executions>
  <configuration>
    <generator>
      <name>org.jooq.util.DefaultGenerator</name>
      <!-- But the custom strategy is not yet compiled -->
      <strategy>
        <name>com.example.MyStrategy</name>
      </strategy>
    </generator>
  </configuration>
</plugin>
以上配置描述了该问题.jOOQ的代码生成器挂钩到Maven生命周期的生成目标,该生成目标发生在生命周期的编译目标之前.但是,对于代码生成,它需要一个预编译的自定义策略类,否则我会得到一个ClassNotFoundException.如何用Maven解决这个问题?我可以在执行generate目标之前编译单个类吗?
更好的解决方案是将项目拆分为两个模块.一个包含策略,另一个包含其余部分.
使用模块,您可以在一个独立的步骤中编译策略,然后在插件中使用该模块:
<plugin>
  <groupId>org.jooq</groupId>
  <artifactId>jooq-codegen-maven</artifactId>
  <version>2.2.2</version>
  ...your config goes here...
  <dependencies>
    list your strategy module here
  </dependencies>
</plugin>