Skip to content

Commit a7e4ca9

Browse files
authored
Merge pull request #865 from kazuki43zoo/gh-855
Corrected to set bean class instead of bean class name to factoryBeanObjectType of BeanDefinition attribute
2 parents 4275397 + a781e86 commit a7e4ca9

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,12 @@ private void processBeanDefinitions(Set<BeanDefinitionHolder> beanDefinitions) {
262262
// but, the actual class of the bean is MapperFactoryBean
263263
definition.getConstructorArgumentValues().addGenericArgumentValue(beanClassName); // issue #59
264264
try {
265+
Class<?> beanClass = Resources.classForName(beanClassName);
266+
// Attribute for MockitoPostProcessor
267+
// https://github.com/mybatis/spring-boot-starter/issues/475
268+
definition.setAttribute(FACTORY_BEAN_OBJECT_TYPE, beanClass);
265269
// for spring-native
266-
definition.getPropertyValues().add("mapperInterface", Resources.classForName(beanClassName));
270+
definition.getPropertyValues().add("mapperInterface", beanClass);
267271
} catch (ClassNotFoundException ignore) {
268272
// ignore
269273
}
@@ -272,10 +276,6 @@ private void processBeanDefinitions(Set<BeanDefinitionHolder> beanDefinitions) {
272276

273277
definition.getPropertyValues().add("addToConfig", this.addToConfig);
274278

275-
// Attribute for MockitoPostProcessor
276-
// https://github.com/mybatis/spring-boot-starter/issues/475
277-
definition.setAttribute(FACTORY_BEAN_OBJECT_TYPE, beanClassName);
278-
279279
boolean explicitFactoryUsed = false;
280280
if (StringUtils.hasText(this.sqlSessionFactoryBeanName)) {
281281
definition.getPropertyValues().add("sqlSessionFactory",

src/test/java/org/mybatis/spring/mapper/MapperScannerConfigurerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2010-2022 the original author or authors.
2+
* Copyright 2010-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -399,7 +399,7 @@ void testMapperBeanAttribute() {
399399
startContext();
400400

401401
assertThat(applicationContext.getBeanDefinition("annotatedMapper")
402-
.getAttribute(ClassPathMapperScanner.FACTORY_BEAN_OBJECT_TYPE)).isEqualTo(AnnotatedMapper.class.getName());
402+
.getAttribute(ClassPathMapperScanner.FACTORY_BEAN_OBJECT_TYPE)).isEqualTo(AnnotatedMapper.class);
403403
}
404404

405405
private void setupSqlSessionFactory(String name) {

0 commit comments

Comments
 (0)