spring-boot-starter icon indicating copy to clipboard operation
spring-boot-starter copied to clipboard

MyBatisAutoConfiguration supports bean name generator

Open 290044632 opened this issue 3 months ago • 0 comments
trafficstars

[description]

1.Add the beanNameGenerator property to the MybatisProperties class for customizing the name generator class of the Mapper bean.

[Test Code]

    @Test
    void withCustomBeanNameGenerator() {
        contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class, CustomBeanNameGeneratorConfiguration.class)
                .withPropertyValues("mybatis.beanNameGenerator:org.springframework.context.annotation.FullyQualifiedAnnotationBeanNameGenerator")
                .run((context) -> {
                    assertThat(context.containsBean(com.example.mapper.two.DateTimeMapper.class.getName())).isTrue();
                    assertThat(context.containsBean(com.example.mapper.one.DateTimeMapper.class.getName())).isTrue();
                });
    }

    @Configuration
    @TestAutoConfigurationPackage(DateTimeMapper.class)
    static class CustomBeanNameGeneratorConfiguration {

    }

290044632 avatar Aug 04 '25 09:08 290044632