很好的一天,
我正在使用jOOQ用java尝试一个简单的postgreSQL设置。现在,我使用pgadmin3创建了一个名为Products的表,其中有两列:
CREATE TABLE public."Products"
(
id integer NOT NULL,
username text,
CONSTRAINT id PRIMARY KEY (id)
)
WITH (
OIDS=FALSE
);
ALTER TABLE public."Products"
OWNER TO postgres;
现在,我尝试使用java与这个表交互。我可以向postgres请求一个表列表,这样我就知道这个连接是有效的。但是,如果我尝试进行maven安装(以generate为目标,我想要我的java类),就会得到以下错误:
[ERROR] /home/dries/workspace/postgres/target/generated-sources/jooq/org/jooq/util/maven/example/PublicFactory.java:[15,58] cannot find symbol
symbol: class PostgresFactory
location: package org.jooq.util.postgres
[ERROR] /home/dries/workspace/postgres/target/generated-sources/jooq/org/jooq/util/maven/example/tables/Products.java:[12,44] cannot find symbol
symbol: class UpdatableTableImpl
location: package org.jooq.impl
[ERROR] /home/dries/workspace/postgres/target/generated-sources/jooq/org/jooq/util/maven/example/Keys.java:[31,120] method createUniqueKey in class org.jooq.impl.AbstractKeys cannot be applied to given types;
required: org.jooq.Table<R>,org.jooq.TableField<R,?>[]
found: org.jooq.util.maven.example.tables.Products,org.jooq.TableField<org.jooq.util.maven.example.tables.records.ProductsRecord,java.lang.Integer>
reason: cannot infer type-variable(s) R
(argument mismatch; org.jooq.util.maven.example.tables.Products cannot be converted to org.jooq.Table<R>)
[ERROR] /home/dries/workspace/postgres/target/generated-sources/jooq/org/jooq/util/maven/example/tables/records/ProductsRecord.java:[52,66] incompatible types: org.jooq.util.maven.example.tables.Products cannot be converted to org.jooq.Table<org.jooq.util.maven.example.tables.records.ProductsRecord>
[ERROR] /home/dries/workspace/postgres/target/generated-sources/jooq/org/jooq/util/maven/example/PublicFactory.java:[83,62] cannot find symbol
symbol: method getSettings()
location: class org.jooq.util.maven.example.PublicFactory
[ERROR] /home/dries/workspace/postgres/target/generated-sources/jooq/org/jooq/util/maven/example/tables/Products.java:[24,9] method does not override or implement a method from a supertype
[ERROR] /home/dries/workspace/postgres/target/generated-sources/jooq/org/jooq/util/maven/example/tables/Products.java:[34,125] cannot find symbol
symbol: method createField(java.lang.String,org.jooq.DataType<java.lang.Integer>,org.jooq.util.maven.example.tables.Products)
location: class org.jooq.util.maven.example.tables.Products
[ERROR] /home/dries/workspace/postgres/target/generated-sources/jooq/org/jooq/util/maven/example/tables/Products.java:[39,130] cannot find symbol
symbol: method createField(java.lang.String,org.jooq.DataType<java.lang.String>,org.jooq.util.maven.example.tables.Products)
location: class org.jooq.util.maven.example.tables.Products
[ERROR] /home/dries/workspace/postgres/target/generated-sources/jooq/org/jooq/util/maven/example/tables/Products.java:[49,9] method does not override or implement a method from a supertype
[ERROR] /home/dries/workspace/postgres/target/generated-sources/jooq/org/jooq/util/maven/example/tables/Products.java:[54,9] method does not override or implement a method from a supertype
[ERROR] /home/dries/workspace/postgres/target/generated-sources/jooq/org/jooq/util/maven/example/tables/Products.java:[60,9] method does not override or implement a method from a supertype
[ERROR] /home/dries/workspace/postgres/target/generated-sources/jooq/org/jooq/util/maven/example/Public.java:[36,40] method asList in class java.util.Arrays cannot be applied to given types;
required: T[]
found: org.jooq.util.maven.example.tables.Products
reason: varargs mismatch; org.jooq.util.maven.example.tables.Products cannot be converted to org.jooq.Table<?>
这个类确实被生成了,看起来(我可以在目标文件夹中找到它)。但是在eclipse或intellij中,我无法在路径中找到它。
不管怎样,构建过程都不应该失败。
有人知道为什么构建失败吗?
谢谢,祝你好运。
最佳答案
所以,为了得到一个关于堆栈溢出的正式答案,这里是我的评论。
从外观上看,您使用的是过时的jOOQ代码生成器版本和较新的jOOQ运行时版本。两者不匹配,这就是为什么你会得到这些例外。
我注意到了,因为jOOQ 3.x代码生成器不再生成PublicFactory
类。