File tree 2 files changed +15
-0
lines changed
main/java/org/mybatis/spring/mapper
test/java/org/mybatis/spring/mapper
2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,9 @@ public class ClassPathMapperScanner extends ClassPathBeanDefinitionScanner {
57
57
58
58
private static final Logger LOGGER = LoggerFactory .getLogger (ClassPathMapperScanner .class );
59
59
60
+ // Copy of FactoryBean#OBJECT_TYPE_ATTRIBUTE which was added in Spring 5.2
61
+ static final String FACTORY_BEAN_OBJECT_TYPE = "factoryBeanObjectType" ;
62
+
60
63
private boolean addToConfig = true ;
61
64
62
65
private boolean lazyInitialization ;
@@ -234,6 +237,10 @@ private void processBeanDefinitions(Set<BeanDefinitionHolder> beanDefinitions) {
234
237
235
238
definition .getPropertyValues ().add ("addToConfig" , this .addToConfig );
236
239
240
+ // Attribute for MockitoPostProcessor
241
+ // https://github.com/mybatis/spring-boot-starter/issues/475
242
+ definition .setAttribute (FACTORY_BEAN_OBJECT_TYPE , beanClassName );
243
+
237
244
boolean explicitFactoryUsed = false ;
238
245
if (StringUtils .hasText (this .sqlSessionFactoryBeanName )) {
239
246
definition .getPropertyValues ().add ("sqlSessionFactory" ,
Original file line number Diff line number Diff line change @@ -385,6 +385,14 @@ void testScanWithMapperFactoryBeanClass() {
385
385
assertTrue (DummyMapperFactoryBean .getMapperCount () > 0 );
386
386
}
387
387
388
+ @ Test
389
+ void testMapperBeanAttribute () {
390
+ startContext ();
391
+
392
+ assertThat (applicationContext .getBeanDefinition ("annotatedMapper" ).getAttribute (ClassPathMapperScanner .FACTORY_BEAN_OBJECT_TYPE ))
393
+ .isEqualTo (AnnotatedMapper .class .getName ());
394
+ }
395
+
388
396
private void setupSqlSessionFactory (String name ) {
389
397
GenericBeanDefinition definition = new GenericBeanDefinition ();
390
398
definition .setBeanClass (SqlSessionFactoryBean .class );
You can’t perform that action at this time.
0 commit comments