How to set R2dbcCustomConversions while using @SpringBootApplication?
Closed this issue · 1 comments
peterfigure commented
when simply declaring a bean of type R2dbcCustomConversions, it fails with:
00:36:33.182 [restartedMain] ERROR o.s.boot.SpringApplication - Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.data.r2dbc.mapping.R2dbcMappingContext': Unexpected exception during bean creation; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'org.springframework.data.r2dbc.convert.R2dbcCustomConversions' available: expected single matching bean but found 2: org.springframework.data.r2dbc.convert.R2dbcCustomConversions#0,org.springframework.data.r2dbc.convert.R2dbcCustomConversions
something like
configuration {
beans {
bean<R2dbcCustomConversions> {}
}
r2dbc {
}
}
even though I notice the bean declared in R2dbcDataAutoConfiguration is declared conditionally:
@Bean
@ConditionalOnMissingBean
public R2dbcCustomConversions r2dbcCustomConversions() {
I believe the above bean is created first (by virtue of @SpringBootApplication), this will make it challenging to partly adopt the kofu DSL which seems to be the desire for others also (#335). My only work around for now is to not use the R2DBC DSL and manually create the required beans.
Sample project illustrating the problem: https://github.com/peterfigure/minimal-kofu - In com.peterfigure.config.ApplicationConfigurationDSL
please uncomment bean<R2dbcCustomConversions>()
to see the issue.