I am trying to setup correctly JOOQ with Spring Boot project which uses reactive stack based on r2dbc driver for Postgres DB. I came across quite few problems and at the very end "hopefully" I stucked on following error:
Caused by: java.lang.NoSuchMethodError: 'org.jooq.DSLContext org.jooq.impl.DSL.using(io.r2dbc.spi.ConnectionFactory)
here is most relevant part of my build.gradle:
compileOnly("org.jooq:jooq:3.17.5")
compileOnly("org.jooq:jooq-codegen:3.17.5")
compileOnly("org.jooq:jooq-meta-extensions:3.17.5")
implementation("org.jooq:jooq-meta:3.17.5")
implementation("org.jooq:jooq-kotlin-coroutines:3.17.5")
implementation("org.jooq:jooq-kotlin:3.17.5")
runtimeOnly("io.r2dbc:r2dbc-postgresql:0.8.13.RELEASE")
runtimeOnly("io.r2dbc:r2dbc-spi:1.0.0.RELEASE")
runtimeOnly("io.r2dbc:r2dbc-pool:1.0.0.RELEASE")
runtimeOnly("org.postgresql:postgresql:42.5.0")
I am running Spring Boot 2.7.5
The cause of exception is from runtime and is in part of the code:
private val dsl = DSL.using(
ConnectionFactories.get(
ConnectionFactoryOptions
.parse(databaseConfig.url)
.mutate()
.option(USER, databaseConfig.username)
.option(PASSWORD, databaseConfig.password)
.build()
)
)
databaseConfig.url: r2dbc:pool:postgresql://localhost:5432/test
Mostly I have tried changing the dependencies versions as I don't have any other valid idea at the moment.
CodePudding user response:
You're using:
compileOnly("org.jooq:jooq:3.17.5")
This means you're using the latest jOOQ version only at compile time (which is why your code compiles), but at runtime, you're using Spring Boot's jOOQ version, which is older. Try changing that to compile
, or add it also to the implementation
section