java - jOOQ:使用 maven 生成代码

标签 java postgresql maven jooq

你好,

我正在使用 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 安装(以生成为目标,我想要我的 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 中我无法在路径中找到它。 无论哪种方式,构建过程都不应失败。

有谁知道构建失败的原因?

谢谢,美好的一天。

最佳答案

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

从外观上看,您使用的是过时的 jOOQ 代码生成器版本和较新的 jOOQ 运行时版本。两者不匹配,这就是您获得这些异常(exception)的原因。

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

关于java - jOOQ:使用 maven 生成代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35703940/

相关文章:

java - 如何从InputStream中读取二进制协议(protocol)?

java - 当我有自定义存储库时,如何使用 Dockerfile 在 Docker 中运行 Maven 项目

eclipse - Eclipse 找不到文件 manifest.mf

java - 无法解析 Criteria API 中的嵌入实体

java - Double 数据类型不返回十进制值 (Java)

java - 如何配置服务器,使其将动态创建的文件存储在指定文件夹中,而不是在 bin 文件夹下?

sql - 使用 row_number 反转对查询进行排名

python - 在python中,如何执行postgresql 'LIKE %name%'查询来减轻SQL注入(inject)?

sql - 删除具有指定参数但在 Postgresql 中最新的所有行

maven - --also-make 和 --also-make-dependents 之间的区别