You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
beanDefinition.getBeanClassName() and existingDef.getBeanClassName() would not be the same.
I'm thinking why scanning for mapper again in aot mode? Shouldn't all beans already been processed in build time?
How about adding skip the scan in org.mybatis.spring.mapper.ClassPathMapperScanner#doScan like
@@ -227,7 +228,11 @@ public class ClassPathMapperScanner extends ClassPathBeanDefinitionScanner {
*/
@Override
public Set<BeanDefinitionHolder> doScan(String... basePackages) {
- Set<BeanDefinitionHolder> beanDefinitions = super.doScan(basePackages);
+ Set<BeanDefinitionHolder> beanDefinitions = new HashSet<>();
+ if (AotDetector.useGeneratedArtifacts()) {
+ return beanDefinitions;
+ }
+ beanDefinitions = super.doScan(basePackages);
if (beanDefinitions.isEmpty()) {
if (printWarnLogIfNotFoundMappers) {
As for the second error, spring 6.1 add support for generic constructor argument values in aot but didn't support string to class convert in this commit
It seems need to change definition.getConstructorArgumentValues().addGenericArgumentValue(beanClassName); also to definition.getConstructorArgumentValues().addGenericArgumentValue(beanClass); like
LOGGER.debug(() -> "Creating MapperFactoryBean with name '" + holder.getBeanName() + "' and '" + beanClassName
+ "' mapperInterface");
- // the mapper interface is the original class of the bean
- // but, the actual class of the bean is MapperFactoryBean
- definition.getConstructorArgumentValues().addGenericArgumentValue(beanClassName); // issue #59
try {
Class<?> beanClass = Resources.classForName(beanClassName);
+ // the mapper interface is the original class of the bean
+ // but, the actual class of the bean is MapperFactoryBean
+ definition.getConstructorArgumentValues().addGenericArgumentValue(beanClass); // issue #59
// Attribute for MockitoPostProcessor
// https://github.com/mybatis/spring-boot-starter/issues/475
definition.setAttribute(FACTORY_BEAN_OBJECT_TYPE, beanClass);
I recently upgrade my spring boot project to 3.2.3 from 3.1.4. After upgrading, when I run in aot mode, it fails with error
and
It appears spring boot 3.2.x is using spring 6.1 and in 6.1 they change the check logic in spring-projects/spring-framework@eaf54b5#diff-02b9877a0a8b049e25dc47ce5b99ae822277865085e27a3944c963b32f87bb90 and spring-projects/spring-framework@e685ff0 causing the first error.
beanDefinition.getBeanClassName()
andexistingDef.getBeanClassName()
would not be the same.I'm thinking why scanning for mapper again in aot mode? Shouldn't all beans already been processed in build time?
How about adding skip the scan in
org.mybatis.spring.mapper.ClassPathMapperScanner#doScan
likeAs for the second error, spring 6.1 add support for generic constructor argument values in aot but didn't support string to class convert in this commit
It seems need to change
definition.getConstructorArgumentValues().addGenericArgumentValue(beanClassName);
also todefinition.getConstructorArgumentValues().addGenericArgumentValue(beanClass);
likedemo_mybatis.zip
will show first error
after change spring.main.allow-bean-definition-overriding to true and package&run again will show second error
uncomment
in
com.example.demo.mybatis.MyBatisMapperFactoryBeanPostProcessor
line 51 and package&run again will run success.The text was updated successfully, but these errors were encountered: