【问题标题】:How to configure pom.xml for generate jooq classes into two different packages?如何配置 pom.xml 以将 jooq 类生成到两个不同的包中?
【发布时间】:2021-11-29 21:33:09
【问题描述】:

我的项目由两个包组成,每个包都使用相同的数据库架构。未来,这两个包都将成为独立的微服务。

问题:如何在 pom.xml 中配置代码生成,以便在两个不同的包(myProject/packageTwo/ DaomyProject/packageOne/Dao)中创建带有 jooq 类的文件夹。

例如,此决定导致仅在第二个文件夹中创建 jooq 类。

<plugin>
 <groupId>org.jooq</groupId>
  <artifactId>jooq-codegen-maven</artifactId>
  <version>3.15.3</version>
…
   <target>
        <packageName>myProject/packageOne/Dao</packageName>
        <directory>target/generated-sources/jooq</directory>
  </target>
  <target>
        <packageName> myProject/packageTwo/Dao</packageName>
        <directory>target/generated-sources/jooq</directory>
  </target>

【问题讨论】:

    标签: maven pom.xml code-generation jooq


    【解决方案1】:

    这更像是一个 Maven 问题而不是一个 jOOQ 问题:您应该配置两个单独的执行,以便拥有两个单独的目标配置:

    <plugin>
      <groupId>org.jooq</groupId>
      <artifactId>jooq-codegen-maven</artifactId>
    
      <!-- shared configuration, can also be moved to pluginManagement -->
      <configuration>...</configuration>
    
      <executions>
        <execution>
          <id>exec-1</id>
          <phase>...</phase>
          <goals><goal>generate</goal></goals>
          <configuration>
            <generator>
              <target>...</target>
            </generator>
          </configuration>
        </execution>
    
        <execution>
          <id>exec-2</id>
          <phase>...</phase>
          <goals><goal>generate</goal></goals>
          <configuration>
            <generator>
              <target>...</target>
            </generator>
          </configuration>
        </execution>
      </executions>
    </plugin>
    

    【讨论】:

      猜你喜欢
      • 2018-12-27
      • 2020-11-11
      • 2011-02-20
      • 2020-05-07
      • 1970-01-01
      • 2020-09-23
      • 2021-12-29
      • 2021-01-27
      • 1970-01-01
      相关资源
      最近更新 更多