【问题标题】:Jooq code generation "excludes" not working with typesafe configJooq 代码生成“排除”不适用于类型安全配置
【发布时间】:2016-01-06 22:19:50
【问题描述】:

我试图排除使用 TypeSafe Config 时由 Liquibase 创建的两个表。

jooq {
    # databasechangelog = Liquibase generated tables
    # databasechangeloglock = Liquibase generated tables
    excludes = "databasechangelog, databasechangeloglock"
  }

当我只提供一个排除项时,例如"databsechangelog",它可以工作。

多个排除项应以逗号分隔 (http://www.jooq.org/doc/2.6/manual/code-generation/codegen-configuration/),但它会生成两个表。

也不允许这样做。

excludes = "databasechangelog", "databasechangeloglock"

在库内部,它的简化调用(注意:getExcludesString

    database.setExcludes(new String[]{StringUtils.defaultString(d1.getExcludes())});

还有其他人遇到过这个问题吗?

这是我的代码生成

      new GenerationTool {
        setConnection(connection)
        run(new Configuration {
          withGenerator(new Generator {
            withName(config.jooq.generatorClass)
            withDatabase(new org.jooq.util.jaxb.Database {
              withIncludes(config.jooq.includes)
              withExcludes(config.jooq.excludes)
              withInputSchema(config.jooq.inputSchema)
              withName(config.jooq.databaseClass)
            })
            withTarget(new Target {
              withPackageName(config.jooq.pkg)
              withDirectory(config.jooq.directory)
            })
            withGenerate(new Generate {
              setDaos(true)
            })
          })
        })
      }

【问题讨论】:

标签: code-generation jooq typesafe-config jooq-sbt-plugin


【解决方案1】:

您引用的是 2.6 版的手册。在过去,我们在包含/排除中使用逗号分隔的表达式列表 - 但不管你信不信,有些人的表/列名中有逗号,这就是我们丢弃逗号的原因。毕竟,包含/排除只是正则表达式,您可以使用“联合运算符”分隔您的各个模式,管道:|

即写:

jooq {
    # databasechangelog = Liquibase generated tables
    # databasechangeloglock = Liquibase generated tables
    excludes = "databasechangelog|databasechangeloglock"
}

这也记录在“功能删除”部分中(查找“逗号分隔”): http://www.jooq.org/doc/latest/manual/reference/migrating-to-3.0

【讨论】:

  • 我永远猜不到|。谢谢,我正用头撞这个。
猜你喜欢
  • 2014-07-21
  • 2018-12-27
  • 2019-06-23
  • 2018-12-15
  • 2016-09-04
  • 2019-05-25
  • 2014-09-04
  • 2021-10-28
  • 2014-09-09
相关资源
最近更新 更多