spring-projects / spring-boot

Spring Boot helps you to create Spring-powered, production-grade applications and services with absolute minimum fuss.
https://spring.io/projects/spring-boot
Apache License 2.0
75.14k stars 40.68k forks source link

Add auto-configuration for JdbcClient #36579

Closed mhalbritter closed 1 year ago

mhalbritter commented 1 year ago

Spring Framework 6.1 introduces the new JdbcClient. We should add an auto-configuration for it.

@jhoeller suggested something like this:

@Configuration(proxyBeanMethods = false)
@ConditionalOnSingleCandidate(NamedParameterJdbcTemplate.class)
@ConditionalOnMissingBean(JdbcClient.class)
class JdbcClientConfiguration {

    @Bean
    @Primary
    JdbcClient jdbcClient(NamedParameterJdbcTemplate jdbcTemplate) {
        return JdbcClient.create(jdbcTemplate);
    }

}
philwebb commented 1 year ago

Reopening as I think we need a MyBean.kt file for the docs.

snicoll commented 1 year ago

Added in 3835e25a1868