我使用java --add-modules java.xml.bind -classpath jooq-3.11.3.jar;jooq-meta-3.11.3.jar;jooq-codegen-3.11.3.jar;postgresql-42.2.4.jar;. org.jooq.codegen.GenerationTool jooq.xml
为我的PostgreSQL 10 USER
表自动生成JOOQ代码。
codegen工具成功完成,但是我的程序无法编译,因为在自动生成的代码中有几个Java语法错误。
下面是一些例子:
PgClass.java
/**
* @deprecated Unknown data type. Please define an explicit {@link org.jooq.Binding} to specify how this type should be handled. Deprecation can be turned off using <deprecationOnUnknownTypes/> in your code generator configuration.
*/
@java.lang.Deprecated
public final TableField<PgClassRecord, Object> RELPARTBOUND = createField("relpartbound", , this, "");
编译器告诉我java: illigal start of expression
PgIndex.java:
/**
* The column <code>pg_catalog.pg_index.indoption</code>.
*/
public final TableField<PgIndexRecord, Object[]> INDOPTION = createField("indoption", .getArrayDataType(), this, "");
编译器告诉我java: as of release 8, 'this' is allowed as the parameter name for the receiver type only, which has to be the first parameter
编辑:
jooq.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration xmlns="http://www.jooq.org/xsd/jooq-codegen-3.11.0.xsd">
<jdbc>
<driver>org.postgresql.Driver</driver>
<url>jdbc:postgresql://localhost:5432/timecoder-api-dev</url>
<user>postgres</user>
<password></password>
</jdbc>
<generator>
<database>
<name>org.jooq.meta.postgres.PostgresDatabase</name>
<includes>.*</includes>
</database>
<target>
<packageName>persistence.database.generated</packageName>
<directory>K:\Data\Dev\Git\timecoder-api\src</directory>
</target>
</generator>
</configuration>
1.8.0_181
我还在GitHub上创建了一个问题:https://github.com/jOOQ/jOOQ/issues/7684
发布于 2018-07-30 07:49:52
感谢您的报道。这是代码生成器中的一个错误:https://github.com/jOOQ/jOOQ/issues/7692
该问题将在jOOQ 3.12.0和3.11.4中修复
发布于 2018-07-24 13:38:49
我的数据库表在Postgres schema "public“中。我忘了在我的jooq.xml中添加<inputSchema>public</inputSchema>
。现在它工作得很好:)
jooq.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration xmlns="http://www.jooq.org/xsd/jooq-codegen-3.11.0.xsd">
<jdbc>
<driver>org.postgresql.Driver</driver>
<url>jdbc:postgresql://localhost:5432/timecoder-api-dev</url>
<user>postgres</user>
<password></password>
</jdbc>
<generator>
<database>
<name>org.jooq.meta.postgres.PostgresDatabase</name>
<inputSchema>public</inputSchema>
<includes>.*</includes>
</database>
<target>
<packageName>persistence.database.generated</packageName>
<directory>K:\Data\Dev\Git\timecoder-api\src</directory>
</target>
</generator>
</configuration>
https://stackoverflow.com/questions/51494099
复制相似问题