2016-02-29 101 views
2

美好的一天,jOOQ:使用maven代码生成

我正在尝试使用jOOQ的java的简单postgreSQL设置。现在,我创建了一个使用pgadmin3称为产品表,有两列:

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安装(与产生为目标,我希望我的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中,我无法在路径中找到它。无论哪种方式,构建过程都不应该失败。

有谁知道为什么构建失败?

感谢和美好的一天。

+1

“'PublicFactory'” - 您使用的是哪种古老版本的jOOQ? :)首先想到升级?另外,你可以发布你的相关'pom.xml'配置吗? –

+0

好主,我在3.7.2上是因为jOOQ,但是我似乎不小心复制了粘贴2.6.4的插件。谷歌的结果有时会导致文档的过时版本。我会责怪周一这个!谢谢卢卡斯:) –

+1

更好的期待周二,然后! –

回答

1

所以,为了在Stack Overflow上有一个正式的答案,这里是我的评论作为答案。

从它看起来的样子,你正在使用过时的JOOQ代码生成器版本和更新的jOOQ运行时版本。这两个不匹配,这就是为什么你得到这些例外。

我注意到因为PublicFactory类不再由jOOQ 3.x代码生成器生成。