mybatis-plus-boot-starter包与mybatis-plus-generator的冲突解决
作者:L564458192
本文主要介绍了mybatis-plus-boot-starter包与mybatis-plus-generator的冲突解决,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
我这里搭建框架时mybatis-plus-boot-starter 包的版本是3.5.0,一定要注意版本,因为现在很多spring高版本的jar包都要求高于jkd8,但是因为学习、开发及维护成本,市面上主流的还是jkd8。
继续说我这次搭建框架所遇到到的问题,先看具体的UBG内容:
2023-04-03 18:23:52.052 [INFO ] org.springframework.data.repository.config.RepositoryConfigurationDelegate 262 Multiple Spring Data modules found, entering strict repository configuration mode 2023-04-03 18:23:52.052 [INFO ] org.springframework.data.repository.config.RepositoryConfigurationDelegate 132 Bootstrapping Spring Data Redis repositories in DEFAULT mode. 2023-04-03 18:23:52.052 [INFO ] org.springframework.data.repository.config.RepositoryConfigurationDelegate 201 Finished Spring Data repository scanning in 9 ms. Found 0 Redis repository interfaces. 2023-04-03 18:23:52.052 [WARN ] org.mybatis.spring.mapper.ClassPathMapperScanner 44 Skipping MapperFactoryBean with name 'baseAuthMapper' and 'com.javahome.dao.mapper.BaseAuthMapper' mapperInterface. Bean already defined with the same name! 2023-04-03 18:23:52.052 [WARN ] org.mybatis.spring.mapper.ClassPathMapperScanner 44 Skipping MapperFactoryBean with name 'baseAuthResourceMapper' and 'com.javahome.dao.mapper.BaseAuthResourceMapper' mapperInterface. Bean already defined with the same name! 2023-04-03 18:23:52.052 [WARN ] org.mybatis.spring.mapper.ClassPathMapperScanner 44 Skipping MapperFactoryBean with name 'baseDeptMapper' and 'com.javahome.dao.mapper.BaseDeptMapper' mapperInterface. Bean already defined with the same name! 2023-04-03 18:23:52.052 [WARN ] org.mybatis.spring.mapper.ClassPathMapperScanner 44 Skipping MapperFactoryBean with name 'baseRoleAuthMapper' and 'com.javahome.dao.mapper.BaseRoleAuthMapper' mapperInterface. Bean already defined with the same name! 2023-04-03 18:23:52.052 [WARN ] org.mybatis.spring.mapper.ClassPathMapperScanner 44 Skipping MapperFactoryBean with name 'baseRoleMapper' and 'com.javahome.dao.mapper.BaseRoleMapper' mapperInterface. Bean already defined with the same name! 2023-04-03 18:23:52.052 [WARN ] org.mybatis.spring.mapper.ClassPathMapperScanner 44 Skipping MapperFactoryBean with name 'baseUserInfoMapper' and 'com.javahome.dao.mapper.BaseUserInfoMapper' mapperInterface. Bean already defined with the same name! 2023-04-03 18:23:52.052 [WARN ] org.mybatis.spring.mapper.ClassPathMapperScanner 44 Skipping MapperFactoryBean with name 'baseUserRoleMapper' and 'com.javahome.dao.mapper.BaseUserRoleMapper' mapperInterface. Bean already defined with the same name! 2023-04-03 18:23:52.052 [WARN ] org.mybatis.spring.mapper.ClassPathMapperScanner 44 Skipping MapperFactoryBean with name 'sysResourceMapper' and 'com.javahome.dao.mapper.SysResourceMapper' mapperInterface. Bean already defined with the same name! 2023-04-03 18:23:52.052 [WARN ] org.mybatis.spring.mapper.ClassPathMapperScanner 44 No MyBatis mapper was found in '[com.javahome.dao.mapper]' package. Please check your configuration. 2023-04-03 18:23:53.053 [WARN ] io.undertow.websockets.jsr 68 UT026010: Buffer pool was not set on WebSocketDeploymentInfo, the default pool will be used 2023-04-03 18:23:53.053 [INFO ] io.undertow.servlet 382 Initializing Spring embedded WebApplicationContext 2023-04-03 18:23:53.053 [INFO ] org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext 292 Root WebApplicationContext: initialization completed in 2210 ms 2023-04-03 18:23:54.054 [WARN ] org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext 591 Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'loginController': Unsatisfied dependency expressed through method 'setRoleService' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'baseRoleServiceImpl': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'baseRoleMapper' defined in file [D:\ctvit_code\springboot-javahome\javahome-dao\target\classes\com\javahome\dao\mapper\BaseRoleMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is java.lang.NoClassDefFoundError: com/baomidou/mybatisplus/core/handlers/PostInitTableInfoHandler 2023-04-03 18:23:54.054 [INFO ] org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener 136 Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2023-04-03 18:23:54.054 [ERROR] org.springframework.boot.SpringApplication 824 Application run failed org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'loginController': Unsatisfied dependency expressed through method 'setRoleService' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'baseRoleServiceImpl': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'baseRoleMapper' defined in file [D:\ctvit_code\springboot-javahome\javahome-dao\target\classes\com\javahome\dao\mapper\BaseRoleMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is java.lang.NoClassDefFoundError: com/baomidou/mybatisplus/core/handlers/PostInitTableInfoHandler at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.resolveMethodArguments(AutowiredAnnotationBeanPostProcessor.java:767) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:719) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1431) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:619) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) at com.javahome.web.JavahomeWebApplication.main(JavahomeWebApplication.java:31) Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'baseRoleServiceImpl': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'baseRoleMapper' defined in file [D:\ctvit_code\springboot-javahome\javahome-dao\target\classes\com\javahome\dao\mapper\BaseRoleMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is java.lang.NoClassDefFoundError: com/baomidou/mybatisplus/core/handlers/PostInitTableInfoHandler at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessProperties(CommonAnnotationBeanPostProcessor.java:332) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1431) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:619) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1391) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1311) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.resolveMethodArguments(AutowiredAnnotationBeanPostProcessor.java:759) ... 20 common frames omitted Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'baseRoleMapper' defined in file [D:\ctvit_code\springboot-javahome\javahome-dao\target\classes\com\javahome\dao\mapper\BaseRoleMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is java.lang.NoClassDefFoundError: com/baomidou/mybatisplus/core/handlers/PostInitTableInfoHandler at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1534) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1417) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:619) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:213) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveBeanByName(AbstractAutowireCapableBeanFactory.java:479) at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:550) at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:520) at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:673) at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:228) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119) at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessProperties(CommonAnnotationBeanPostProcessor.java:329) ... 31 common frames omitted Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is java.lang.NoClassDefFoundError: com/baomidou/mybatisplus/core/handlers/PostInitTableInfoHandler at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658) at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:638) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1391) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1311) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1519) ... 45 common frames omitted Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is java.lang.NoClassDefFoundError: com/baomidou/mybatisplus/core/handlers/PostInitTableInfoHandler at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653) ... 58 common frames omitted Caused by: java.lang.NoClassDefFoundError: com/baomidou/mybatisplus/core/handlers/PostInitTableInfoHandler at com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration.sqlSessionFactory(MybatisPlusAutoConfiguration.java:215) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ... 59 common frames omitted Caused by: java.lang.ClassNotFoundException: com.baomidou.mybatisplus.core.handlers.PostInitTableInfoHandler at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 65 common frames omitted Disconnected from the target VM, address: '127.0.0.1:56832', transport: 'socket' Process finished with exit code 1
我的pom.xml引用:
<!-- 引入Druid依赖,阿里巴巴所提供的数据源 --> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>1.0.28</version> </dependency> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.5.3</version> </dependency> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-generator</artifactId> <version>3.5.3</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.29</version> </dependency>
具体是什么原因导致的不清楚,直接说解决办法:问题就在mybatis-plus-generator 这个包及版本上,将mybatis-plus-generator删除,并降低版本至3.5.0,项目正常启动访问。
到此这篇关于mybatis-plus-boot-starter包与mybatis-plus-generator的冲突的文章就介绍到这了,更多相关mybatis-plus-boot-starter与mybatis-plus-generator内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!