File tree 2 files changed +14
-0
lines changed
main/java/org/mybatis/spring/mapper
test/java/org/mybatis/spring/mapper
2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change 26
26
import org .mybatis .spring .SqlSessionTemplate ;
27
27
import org .springframework .aop .scope .ScopedProxyFactoryBean ;
28
28
import org .springframework .aop .scope .ScopedProxyUtils ;
29
+ import org .springframework .beans .factory .FactoryBean ;
29
30
import org .springframework .beans .factory .annotation .AnnotatedBeanDefinition ;
30
31
import org .springframework .beans .factory .config .BeanDefinition ;
31
32
import org .springframework .beans .factory .config .BeanDefinitionHolder ;
@@ -234,6 +235,10 @@ private void processBeanDefinitions(Set<BeanDefinitionHolder> beanDefinitions) {
234
235
235
236
definition .getPropertyValues ().add ("addToConfig" , this .addToConfig );
236
237
238
+ // Attribute for MockitoPostProcessor
239
+ // https://github.com/mybatis/spring-boot-starter/issues/475
240
+ definition .setAttribute (FactoryBean .OBJECT_TYPE_ATTRIBUTE , beanClassName );
241
+
237
242
boolean explicitFactoryUsed = false ;
238
243
if (StringUtils .hasText (this .sqlSessionFactoryBeanName )) {
239
244
definition .getPropertyValues ().add ("sqlSessionFactory" ,
Original file line number Diff line number Diff line change 37
37
import org .mybatis .spring .SqlSessionTemplate ;
38
38
import org .mybatis .spring .mapper .child .MapperChildInterface ;
39
39
import org .mybatis .spring .type .DummyMapperFactoryBean ;
40
+ import org .springframework .beans .factory .FactoryBean ;
40
41
import org .springframework .beans .factory .NoSuchBeanDefinitionException ;
41
42
import org .springframework .beans .factory .config .BeanDefinition ;
42
43
import org .springframework .beans .factory .config .ConstructorArgumentValues ;
@@ -385,6 +386,14 @@ void testScanWithMapperFactoryBeanClass() {
385
386
assertTrue (DummyMapperFactoryBean .getMapperCount () > 0 );
386
387
}
387
388
389
+ @ Test
390
+ void testMapperBeanAttribute () {
391
+ startContext ();
392
+
393
+ assertThat (applicationContext .getBeanDefinition ("annotatedMapper" ).getAttribute (FactoryBean .OBJECT_TYPE_ATTRIBUTE ))
394
+ .isEqualTo (AnnotatedMapper .class .getName ());
395
+ }
396
+
388
397
private void setupSqlSessionFactory (String name ) {
389
398
GenericBeanDefinition definition = new GenericBeanDefinition ();
390
399
definition .setBeanClass (SqlSessionFactoryBean .class );
You can’t perform that action at this time.
0 commit comments