spring-boot-starter
spring-boot-starter copied to clipboard
MyBatisAutoConfiguration supports bean name generator
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 {
}