【发布时间】:2021-04-28 11:01:00
【问题描述】:
我在关注here。我使用postgresql 而不是h2。我能够使用一些额外的字段来构建项目。
我在com.example.demo下创建了一个包database,但是项目建好后还是空的。
build.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 列的表。
当我输入./gradlew generate 时BUILD SUCCESSFULL,但没有生成任何内容。
【问题讨论】:
-
@LukasEder,感谢您的参与。输出仅显示
build success。我假设一旦我输入./gradlew clean build,它就会被调用。我想我要么在教程之间迷路了,要么错过了一些东西。 -
嘿,您找到解决方案了吗?我有完全相同的问题。 @Eniss
标签: java spring postgresql spring-boot jooq