生成的接口
适用于 ✅ 开源版 ✅ 专业版 ✅ 企业版
数据库中的每个表、视图、udt 都将生成一个如下所示的接口
public interface IBook extends java.io.Serializable {
// Every column generates a getter and a setter
public void setId(Integer value);
public Integer getId();
// [...]
}
这些接口的目的是能够抽象 jOOQ 生成的记录和 POJO。
控制接口生成的标志
XML(独立和 Maven)
编程方式
Gradle (Kotlin)
Gradle (Groovy)
Gradle(第三方)
<configuration>
<generator>
<generate>
<!-- Turn on the generation of interfaces -->
<interfaces>true</interfaces>
<!-- Generated interfaces will not expose mutable components of their implementations, such as setters -->
<immutableInterfaces>true</immutableInterfaces>
<!-- Whether generated interfaces are Serializable -->
<serializableInterfaces>true</serializableInterfaces>
</generate>
</generator>
</configuration>
有关更多详细信息,请参见配置 XSD、独立代码生成和maven 代码生成。
new org.jooq.meta.jaxb.Configuration()
.withGenerator(
new Generate()
// Turn on the generation of interfaces
.withInterfaces(true)
// Generated interfaces will not expose mutable components of their implementations, such as setters
.withImmutableInterfaces(true)
// Whether generated interfaces are Serializable
.withSerializableInterfaces(true)
)
import org.jooq.meta.jaxb.*
configuration {
generator {
generate {
// Turn on the generation of interfaces
isInterfaces = true
// Generated interfaces will not expose mutable components of their implementations, such as setters
isImmutableInterfaces = true
// Whether generated interfaces are Serializable
isSerializableInterfaces = true
}
}
}
有关更多详细信息,请参见配置 XSD和gradle 代码生成。
configuration {
generator {
generate {
// Turn on the generation of interfaces
interfaces = true
// Generated interfaces will not expose mutable components of their implementations, such as setters
immutableInterfaces = true
// Whether generated interfaces are Serializable
serializableInterfaces = true
}
}
}
有关更多详细信息,请参见配置 XSD和gradle 代码生成。
// The jOOQ-codegen-gradle plugin has been introduced in version 3.19. // Please use the official plugin instead of the third party plugin that was recommended before.
请注意,生成的接口存在许多问题,如 #10509 所示。
反馈
您对此页面有任何反馈吗? 我们很乐意听取您的意见!