首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >jOOQ:用maven生成代码

jOOQ:用maven生成代码
EN

Stack Overflow用户
提问于 2016-02-29 15:58:25
回答 1查看 1.4K关注 0票数 3

日安,

我正在试用一个简单的postgreSQL设置,并使用java使用jOOQ。现在,我使用pgadmin3创建了一个名为Products的表,其中有两列:

代码语言:javascript
复制
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类),我会得到以下错误:

代码语言:javascript
复制
[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中,我无法在路径中找到它。无论哪种方式,构建过程都不应该失败。

有人知道为什么构建失败了吗?

谢谢,祝你愉快。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-03-01 12:35:41

因此,为了在Stack溢出上有一个正式的答案,这里我的评论再次作为一个答案。

从外观上看,您使用的是过时的jOOQ代码生成器版本和更新的jOOQ运行时版本。两者是不匹配的,这就是为什么你要得到这些异常。

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

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35703940

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档