java - JOOQ 不生成
问题描述
我跟着这里。我用postgresql
而不是h2
. 我能够用一些额外的字段来构建项目。
database
我在下创建了一个包com.example.demo
,但是在项目构建后它仍然是空的。
构建.gradle:
buildscript {
ext {
springBootVersion = '2.4.2'
}
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath 'org.jooq:jooq-codegen:3.14.4'
classpath 'org.postgresql:postgresql:42.2.18'
}
}
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '15'
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-jooq'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.flywaydb:flyway-core'
runtimeOnly 'org.postgresql:postgresql'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
test {
useJUnitPlatform()
}
import org.jooq.codegen.GenerationTool
import org.jooq.meta.jaxb.*
task generate {
def configuration = new Configuration()
configuration
.withJdbc(new Jdbc()
.withDriver('org.postgresql.Driver')
.withUrl('jdbc:postgresql://localhost:5432/vertx')
.withUser('postgres')
.withPassword('postgres'))
.withGenerator(new Generator()
.withDatabase(new Database().withInputSchema('public'))
.withGenerate(new Generate()
.withPojos(true)
.withDaos(true))
.withTarget(new Target()
.withPackageName('com.example.demo.database')
.withDirectory('src/main/java')))
doLast {
GenerationTool.generate(configuration)
}
}
有什么我想念的吗?为什么我在database
包中看不到 pojos 和 daos?我的数据库只有一张有 2 列的表。
BUILD SUCCESSFULL
当我键入时./gradlew generate
,但没有生成任何内容。
解决方案
你的文件看起来不错。我有一个类似的问题(在使用 Maven 时)。尝试三件事(对我有用):
- 检查“withInputSchema”属性中模式的大小写。尝试传递大写的PUBLIC。
- 尝试将 'src/main/java' 更改为 './src/main/java'
- 添加“包含”并在其中传递 .* (为架构中的所有表生成)
推荐阅读
- remote-access - rdp 正在断开连接
- javascript - Azure Text to Speech Throttled due to too many requests websocket error code: 1007 with only 3 concurrent requests
- google-cloud-platform - GCP - 我们可以强制用户在创建资源时添加标签吗?
- active-directory - 根据授权码获取自定义策略名称
- swift - 如何让 UIView 背景变成磨砂黑色?迅速?
- nuxt.js - PurgeCSS 忽略 whitelistPatterns 中的正则表达式并删除 TailwindCSS 类(在 NuxtJS 上)
- python - 如何使函数等于变量?
- sbt - 我收到这个 sbt 错误,有什么办法可以解决这个问题
- list - Dart:我如何计算一个特定整数列表的平均值,其中 X 个其他整数列表只有一个函数
- c# - 图像不会改变 - WPF