简体   繁体   English

如何将JOOQ生成器设置为不使用包名称作为前缀类型

[英]How can I set the JOOQ generator up to not prefix types with package names

I have generated classes from my database Schema with JOOQ. 我已经使用JOOQ从我的数据库Schema生成了类。 All types are prefixed with their package names in the generated classes (eg org.jooq.TableField). 所有类型都在生成的类中以其包名称作为前缀(例如org.jooq.TableField)。 This makes the generated code barely readable. 这使得生成的代码几乎不可读。 Can I parametrize the generator such that it only imports the pacakges and then specifies the types without the packages (eg TableField) ? 我可以参数化生成器,使其只导入pacakges然后指定没有包的类型(例如TableField)吗?

Here is my configuration xml: 这是我的配置xml:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration xmlns="http://www.jooq.org/xsd/jooq-codegen-3.3.0.xsd">
  <jdbc>
    <driver>com.mysql.jdbc.Driver</driver>
    <url>jdbc:mysql://localhost:3306/mydb</url>
    <user>root</user>
    <password></password>
  </jdbc>

  <generator>
    <name>org.jooq.util.DefaultGenerator</name>

    <database>
      <name>org.jooq.util.mysql.MySQLDatabase</name>
      <inputSchema>mydb</inputSchema>
      <includes>.*</includes>

      <excludes></excludes>
    </database>

    <target>
      <packageName>my.package.for.generated.classes</packageName>

      <directory>/home/nicolas/dev/Java/my.project/src/main/java/</directory>
    </target>
  </generator>
</configuration>

jOOQ currently doesn't support generating import statements because of all the possible naming clashes with existing types. 由于现有类型的所有可能命名冲突,jOOQ目前不支持生成import语句。 In other words, it's not possible to prevent that with jOOQ 3.3. 换句话说,使用jOOQ 3.3无法阻止这种情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM