生成jOOQ java表类,无需包中的数据库/模式

问题描述 投票:0回答:1

我正在运行 jOOQ 生成工具(jdk11+ 试用版),它为每个表生成正确的 Java 类,但是该包包含数据库名称和架构。我想在包中省略这两个。我在 SQL Server 2022 Developer Edition 上运行此程序。

java -classpath jooq-3.19.9.jar;jooq-meta-3.19.9.jar;jooq-codegen-3.19.9.jar;jakarta.xml.bind-api-3.0.0.jar;r2dbc-spi-1.0.0.RELEASE.jar;reactive-streams-1.0.3.jar;mssql-jdbc-12.6.2.jre11.jar;. org.jooq.codegen.GenerationTool ss.xml

它生成包:

package dbmetab.bank_dd_0002.dbo.tables;

我需要的包裹是:

package dbmetab.tables;

这是 ss.xml:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration xmlns="http://www.jooq.org/xsd/jooq-codegen-3.11.0.xsd">
  <!-- Configure the database connection here -->
  <jdbc>
    <driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver>
    <url>jdbc:sqlserver://;serverName=localhost;databaseName=bank_dd_0002;encrypt=false</url>
    <user>abc</user>
    <password>xxx</password>
  </jdbc>
  <generator>
    <!-- The default code generator. You can override this one, to generate your own code style.
         Supported generators:
         - org.jooq.codegen.JavaGenerator
         - org.jooq.codegen.ScalaGenerator
         Defaults to org.jooq.codegen.JavaGenerator -->
    <name>org.jooq.codegen.JavaGenerator</name>
    <database>
      <!-- The database type. The format here is:
           org.util.[database].[database]Database -->
      <name>org.jooq.meta.sqlserver.SQLServerDatabase</name>
      <!-- The database schema (or in the absence of schema support, in your RDBMS this
           can be the owner, user, database name) to be generated -->
      <!-- All elements that are generated from your schema
           (A Java regular expression. Use the pipe to separate several expressions)
           Watch out for case-sensitivity. Depending on your database, this might be important! -->
      <inputSchema>dbo</inputSchema>
      <includes>
           app_dates|dates|holidays|banks|bank_groups|bank_group_banks
      </includes>
      <!-- All elements that are excluded from your schema
           (A Java regular expression. Use the pipe to separate several expressions).
           Excludes match before includes, i.e. excludes have a higher priority -->
      <excludes></excludes>
    </database>
    <target>
      <!-- The destination package of your generated classes (within the destination directory) -->
      <packageName>dbmetab</packageName>
      <!-- The destination directory of your generated classes. Using Maven directory layout here -->
      <directory>C:\appdir\src\main\java</directory>
    </target>
  </generator>
</configuration>
jooq jooq-codegen
1个回答
0
投票

是的,通过在代码生成或运行时禁用或映射模式渲染。

https://www.jooq.org/doc/latest/manual/sql-building/dsl-context/custom-settings/settings-render-mapping/

© www.soinside.com 2019 - 2024. All rights reserved.