可用版本:Dev (3.21) | 最新版 (3.20) | 3.19 | 3.18 | 3.17 | 3.16 | 3.15 | 3.14 | 3.13 | 3.12

空格(换行和缩进)

适用于 ✅ 开源版   ✅ 专业版   ✅ 企业版

默认情况下,jOOQ 的代码生成器会生成 Unix 换行符 (\n) 和 4 个空格缩进(Java)或 2 个空格缩进(Scala)。这可以通过使用以下配置标志来覆盖。根据您加载配置的方式,空格字符可能会丢失,这就是为什么您可能需要将反斜杠 \ 转义为 \\。支持的转义序列包括

  • 缩进:\t(制表符)和 \s(空格)
  • 换行:\r(回车)和 \n(换行)
XML(独立和 Maven)
编程方式
Gradle (Kotlin)
Gradle (Groovy)
Gradle(第三方)
<configuration>
  <generator>
    <generate>
      
      <indentation>\s\t</indentation>
      <newline>\r\n</newline>

      <!-- The number of characters after which Javadoc is line-wrapped. 0 to turn off line wrapping. -->
      <printMarginForBlockComment>80</printMarginForBlockComment>
    </generate>
  </generator>
</configuration>

有关更多详细信息,请参阅配置 XSD独立代码生成maven 代码生成

new org.jooq.meta.jaxb.Configuration()
  .withGenerator(
    new Generate()
      .withIndentation("\\s\\t")
      .withNewline("\\r\\n")

      // The number of characters after which Javadoc is line-wrapped. 0 to turn off line wrapping.
      .withPrintMarginForBlockComment(80)
  )

有关更多详细信息,请参阅配置 XSD程序化代码生成

import org.jooq.meta.jaxb.*


configuration {
  generator {
    generate {
      indentation = "\\s\\t"
      newline = "\\r\\n"

      // The number of characters after which Javadoc is line-wrapped. 0 to turn off line wrapping.
      printMarginForBlockComment = 80
    }
  }
}

有关更多详细信息,请参阅配置 XSDgradle 代码生成

configuration {
  generator {
    generate {
      indentation = "\\s\\t"
      newline = "\\r\\n"

      // The number of characters after which Javadoc is line-wrapped. 0 to turn off line wrapping.
      printMarginForBlockComment = 80
    }
  }
}

有关更多详细信息,请参阅配置 XSDgradle 代码生成

// The jOOQ-codegen-gradle plugin has been introduced in version 3.19.
// Please use the official plugin instead of the third party plugin that was recommended before.

反馈

您对此页面有任何反馈吗?我们很乐意听取您的意见!

The jOOQ Logo