Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrected to set bean class instead of bean class name to factoryBeanObjectType of BeanDefinition attribute #865

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,12 @@ private void processBeanDefinitions(Set<BeanDefinitionHolder> beanDefinitions) {
// but, the actual class of the bean is MapperFactoryBean
definition.getConstructorArgumentValues().addGenericArgumentValue(beanClassName); // issue #59
try {
Class<?> beanClass = Resources.classForName(beanClassName);
// Attribute for MockitoPostProcessor
// https://github.com/mybatis/spring-boot-starter/issues/475
definition.setAttribute(FACTORY_BEAN_OBJECT_TYPE, beanClass);
// for spring-native
definition.getPropertyValues().add("mapperInterface", Resources.classForName(beanClassName));
definition.getPropertyValues().add("mapperInterface", beanClass);
} catch (ClassNotFoundException ignore) {
// ignore
}
Expand All @@ -272,10 +276,6 @@ private void processBeanDefinitions(Set<BeanDefinitionHolder> beanDefinitions) {

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

// Attribute for MockitoPostProcessor
// https://github.com/mybatis/spring-boot-starter/issues/475
definition.setAttribute(FACTORY_BEAN_OBJECT_TYPE, beanClassName);

boolean explicitFactoryUsed = false;
if (StringUtils.hasText(this.sqlSessionFactoryBeanName)) {
definition.getPropertyValues().add("sqlSessionFactory",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2022 the original author or authors.
* Copyright 2010-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -399,7 +399,7 @@ void testMapperBeanAttribute() {
startContext();

assertThat(applicationContext.getBeanDefinition("annotatedMapper")
.getAttribute(ClassPathMapperScanner.FACTORY_BEAN_OBJECT_TYPE)).isEqualTo(AnnotatedMapper.class.getName());
.getAttribute(ClassPathMapperScanner.FACTORY_BEAN_OBJECT_TYPE)).isEqualTo(AnnotatedMapper.class);
}

private void setupSqlSessionFactory(String name) {
Expand Down