spring-projects-experimental / spring-fu

Configuration DSLs for Spring Boot
Apache License 2.0
1.67k stars 139 forks source link

provide a way to use pure spring-r2dbc without spring-data-r2dbc dependency #314

Closed pull-vert closed 3 years ago

pull-vert commented 4 years ago

Right now this is impossible because the last line of R2dbcDsl requires spring-data-r2dbc dependency or else throws some java.lang.NoClassDefFoundError (for example on org/springframework/data/r2dbc/core/R2dbcEntityTemplate).

override fun initialize(context: GenericApplicationContext) {
    super.initialize(context)
    init()

    val properties = r2dbcProperties()

    R2dbcInitializer(properties, optionsCustomizers, transactional).initialize(context)
    R2dbcDataInitializer().initialize(context)
}
gytis-ivaskevicius commented 4 years ago

Actually this is a great idea, and may i add that https://github.com/JetBrains/Exposed is going to be getting r2dbc support in near future which means that r2dbc context could be reused depending on library used

sdeleuze commented 3 years ago

@pull-vert spring-r2dbc is very low level and the new spring-data-r2dbc that leverage it pretty lightweight, what is your use case for it?

@gytis-ivaskevicius Initializers are distincts so we should be able to use R2dbcInitializer in a potential Exposed support.

pull-vert commented 3 years ago

@sdeleuze the use case I have is visible in my spring-r2dbc-sample that is using kofu together with kotysa-spring-r2dbc.

I needed to add spring-data-r2dbc dependency so I can use kofu's r2dbc DSL for the reason I explained, whereas spring-r2dbc should be sufficient for my kotysa-spring-r2dbc use.

This is mostly a consistency issue, because my spring-jdbc-sample that is using kofu together with kotysa-spring-jdbc uses kofu's jdbc DSL with only spring-jdbc dependency, without the need of spring-data-jdbc.

sdeleuze commented 3 years ago

Yeah good point, I guess we should put Spring Data config in a dedicated namespace with data { r2dbc { } } or dataR2dbc { }, same for JDBC.

fteychene commented 3 years ago

I ~drafted~ created a PR #342 with a design of dsl to separate r2dbc and spring-data r2dbc. ~If it's okay for this design I will add Jafu one in the PR to be merged~