mybatis-plus-boot-starter包與mybatis-plus-generator的沖突解決
我這里搭建框架時mybatis-plus-boot-starter 包的版本是3.5.0,一定要注意版本,因?yàn)楝F(xiàn)在很多spring高版本的jar包都要求高于jkd8,但是因?yàn)閷W(xué)習(xí)、開發(fā)及維護(hù)成本,市面上主流的還是jkd8。
繼續(xù)說我這次搭建框架所遇到到的問題,先看具體的UBG內(nèi)容:
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依賴,阿里巴巴所提供的數(shù)據(jù)源 -->
<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>具體是什么原因?qū)е碌牟磺宄?,直接說解決辦法:問題就在mybatis-plus-generator 這個包及版本上,將mybatis-plus-generator刪除,并降低版本至3.5.0,項(xiàng)目正常啟動訪問。
到此這篇關(guān)于mybatis-plus-boot-starter包與mybatis-plus-generator的沖突的文章就介紹到這了,更多相關(guān)mybatis-plus-boot-starter與mybatis-plus-generator內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
基于Java編寫一個簡單的內(nèi)部網(wǎng)段掃描程序
這篇文章主要為大家詳細(xì)介紹了如何基于Java編寫一個簡單的內(nèi)部網(wǎng)段掃描程序,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以跟隨小編一起了解下2025-02-02
用java實(shí)現(xiàn)的獲取優(yōu)酷等視頻縮略圖的實(shí)現(xiàn)代碼
想獲取優(yōu)酷等視頻縮略圖,在網(wǎng)上沒有找到滿意的資料,參考了huangdijia的PHP版工具一些思路,寫了下面的JAVA版代碼。。其實(shí)也可以做成JS版的2013-05-05
基于java ssm springboot實(shí)現(xiàn)選課推薦交流平臺系統(tǒng)
這篇文章主要介紹了選課推薦交流平臺系統(tǒng)是基于java ssm springboot來的實(shí)現(xiàn)的,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2021-08-08
詳解spring mvc4使用及json 日期轉(zhuǎn)換解決方案
本篇文章主要介紹了spring mvc4使用及json 日期轉(zhuǎn)換解決方案,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-01-01
mall整合SpringSecurity及JWT認(rèn)證授權(quán)實(shí)戰(zhàn)下
這篇文章主要為大家介紹了mall整合SpringSecurity及JWT認(rèn)證授權(quán)實(shí)戰(zhàn)第二篇,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-06-06
深入學(xué)習(xí)springboot線程池的使用和擴(kuò)展
這篇文章主要介紹了深入學(xué)習(xí)springboot線程池的使用和擴(kuò)展,springboot框架提供了@Async注解,幫助我們更方便的將業(yè)務(wù)邏輯提交到線程池中異步執(zhí)行,需要的朋友可以參考下2019-06-06

