jOOQ with java 15: both interface org.jooq.Record in org.jooq and class java.lang.Record in java.lang match

huangapple go评论79阅读模式
英文:

jOOQ with java 15: both interface org.jooq.Record in org.jooq and class java.lang.Record in java.lang match

问题

我刚刚尝试将我的项目升级到Java 15,现在出现以下错误:

接口org.jooq中的org.jooq.Record与java.lang中的类java.lang.Record匹配。

是否有人有解决这个问题的经验?

英文:

I've just tried upgrading my project to Java 15, and now I get the following error:

  both interface org.jooq.Record in org.jooq and class java.lang.Record in java.lang match

Does anybody have some experience resolving this issue?

答案1

得分: 10

除了Aniket已经说过的内容之外:

对于Record类型,导入-on-demand不再起作用

建议的做法是在导入-on-demand语句中添加显式导入:

import org.jooq.*;
import org.jooq.Record;

或者完全停止使用导入-on-demand。例如,在Eclipse中,您可以使用“整理导入”功能将所有导入-on-demand语句扩展为显式导入,具体取决于您实际使用的类型。

使用类型推断

如果在局部变量中出现这个问题,另一种防止这个问题的方法是使用var

var record = ctx.fetchOne(TABLE, TABLE.ID.eq(1));

现在您不需要导入该类型。当然,这对于成员类型、方法参数和返回类型是不起作用的。

我们将尝试更好地记录这个问题:https://github.com/jOOQ/jOOQ/issues/10646

英文:

In addition to what Aniket already said:

Import-on-demand no longer works for Record

The recommendation is to add an explicit import to your import-on-demand statement:

import org.jooq.*;
import org.jooq.Record;

Or to stop using import-on-demand entirely. E.g. in Eclipse, you can use the "Organize Imports" feature to expand all your import-on-demand statements to explicit imports, depending on the types you're actually using.

Using type inference

Another way to prevent this problem if it happens with local variables is to use var:

var record = ctx.fetchOne(TABLE, TABLE.ID.eq(1));

Now you don't have to import the type. This doesn't work with member types, method parameter and return types, of course.

We'll try to better document this: https://github.com/jOOQ/jOOQ/issues/10646

答案2

得分: 5

Java 14引入了recordsjava.lang.Recordrecord的超类,由于java.lang中的每种类型都会被自动导入,它与org.jooq.Record发生了冲突。有两种解决方案:

  1. 使用完全限定的名称替代Record,并移除导入语句。例如:使用org.jooq.Record代替Record。(不要忘记移除import语句)。
  2. org.jooq.Record重新声明为某个特定的名称。(在您的情况下,我认为这是不可能的,因为它是一个第三方库。)
英文:

Java 14 introduced records. java.lang.Record is a superclass of record which is conflicting with org.jooq.Record since every type in java.lang is auto imported. There are two solutions:

  1. Use a fully qualified name instead of Record and remove the import. Eg: org.jooq.Record instead of Record. (Don't forget to remove the import statement).
  2. Redeclare the org.jooq.Record to something specific. (Which I believe is not possible in your case as it's a third-party library.)

huangapple
  • 本文由 发表于 2020年9月17日 20:57:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/63938525.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定