欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

mybatis和mybatis-plus同時使用的坑

 更新時間:2023年05月29日 14:53:27   作者:馬格南之鷹  
本文主要介紹了mybatis和mybatis-plus同時使用的坑,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習或者工作具有一定的參考學(xué)習價值,需要的朋友們下面隨著小編來一起學(xué)習學(xué)習吧

原項目基于mybatis開發(fā),新功能基于mybatis-plus開發(fā),同時依賴如下兩個jar包

  • mybatis-spring-boot-starter
  • mybatis-plus-boot-starter

啟動時報錯:java.lang.NoClassDefFoundError: org/mybatis/logging/LoggerFactory,詳情如下:

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: org/mybatis/logging/LoggerFactory
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:643)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:130)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1422)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:879)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
    at com.xxx.XXXApplication.main(XXXApplication.java:24)

解決方法:

刪除 mybatis-spring-boot-starter依賴,更新依賴(idea中在pom.xml文件上右鍵,執(zhí)行maven->reload project)

啟動后錯Invalid bound statement (not found)

[TRACEID:] 2021-03-26T10:48:21,900 ERROR [main] c.a.b.c.XXXXDataLoader:31 DefaultRangeDataLoader error info = Invalid bound statement (not found): com.xxx.dao.mapper.XXXMapper.xxx
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.xxx.dao.mapper.XXXMapper.xxx
    at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:235)
    at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.<init>(MybatisMapperMethod.java:50)
    at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.lambda$cachedMapperMethod$0(MybatisMapperProxy.java:101)
    at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)
    at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.cachedMapperMethod(MybatisMapperProxy.java:100)
    at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:95)
    at com.sun.proxy.$Proxy250.subscribeSizeStatistics(Unknown Source)

解決方法: 

將服務(wù)配置文件中mybatis.mapper-locations的配置挪到mybatis-plus下,樣例如下:

原配置如下:

mybatis:
    mapper-locations: classpath:mybatis/*.xml

新配置:

mybatis-plus:
    mapper-locations: classpath:mybatis/*.xml,classpath:/mybatis-plus/*.xml

到此這篇關(guān)于mybatis和mybatis-plus同時使用的坑的文章就介紹到這了,更多相關(guān)mybatis和mybatis-plus同時使用內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • 實戰(zhàn)分布式醫(yī)療掛號系統(tǒng)之整合Swagger2到通用模塊

    實戰(zhàn)分布式醫(yī)療掛號系統(tǒng)之整合Swagger2到通用模塊

    這篇文章主要為大家介紹了實戰(zhàn)分布式醫(yī)療掛號系統(tǒng)之整合Swagger2到通用模塊,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2022-04-04
  • Spring的@Autowired加到接口上但獲取的是實現(xiàn)類的問題

    Spring的@Autowired加到接口上但獲取的是實現(xiàn)類的問題

    這篇文章主要介紹了Spring的@Autowired加到接口上但獲取的是實現(xiàn)類的問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-10-10
  • Java設(shè)計模式之抽象工廠模式簡析

    Java設(shè)計模式之抽象工廠模式簡析

    這篇文章主要介紹了Java設(shè)計模式之抽象工廠模式簡析, 抽象工廠模式是工廠方法模式的升級版本,他用來創(chuàng)建一組相關(guān)或者相互依賴的對象,他與工廠方法模式的區(qū)別就在于,工廠方法模式針對的是一個產(chǎn)品等級結(jié)構(gòu),需要的朋友可以參考下
    2023-12-12
  • java中常見XML解析器的使用詳解(JAXP,DOM4J,Jsoup,JsoupXPath)

    java中常見XML解析器的使用詳解(JAXP,DOM4J,Jsoup,JsoupXPath)

    為了處理和操作XML數(shù)據(jù),我們需要使用XML解析器,本文將介紹幾種常用的XML解析器,包括JAXP、DOM4J、Jsoup和JsoupXPath,需要的小伙伴可以參考一下
    2023-11-11
  • Java中List集合的常用方法詳解

    Java中List集合的常用方法詳解

    本篇文章給大家?guī)淼膬?nèi)容是關(guān)于Java中List集合的常用方法詳解,有一定的參考價值,有需要的朋友可以參考一下,希望對你有所幫助。下面我們就來學(xué)習一下吧
    2021-11-11
  • MyBatis中批量插入和批量更新的實現(xiàn)方法詳解

    MyBatis中批量插入和批量更新的實現(xiàn)方法詳解

    這篇文章主要介紹了MyBatis中批量插入和批量更新的實現(xiàn)方法,在日常開發(fā)中有時候需要從A數(shù)據(jù)庫提取大量數(shù)據(jù)同步到B系統(tǒng),這種情況自然是需要批量操作才行,感興趣想要詳細了解可以參考下文
    2023-05-05
  • 5個步驟讓你明白多線程和線程安全

    5個步驟讓你明白多線程和線程安全

    本文詳細講解了多線程和線程安全的實現(xiàn),文中通過示例代碼介紹的非常詳細。對大家的學(xué)習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2021-12-12
  • Java字符串的壓縮與解壓縮的兩種方法

    Java字符串的壓縮與解壓縮的兩種方法

    這篇文章主要介紹了Java字符串的壓縮與解壓縮的兩種方法,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習或者工作具有一定的參考學(xué)習價值,需要的朋友們下面隨著小編來一起學(xué)習學(xué)習吧
    2021-03-03
  • 2020年IntelliJ IDEA最新最詳細配置圖文教程詳解

    2020年IntelliJ IDEA最新最詳細配置圖文教程詳解

    這篇文章主要介紹了2020年IntelliJ IDEA最新最詳細配置圖文教程詳解,本文通過圖文并茂的形式給大家介紹的非常詳細,對大家的學(xué)習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2021-02-02
  • spring boot項目如何采用war在tomcat容器中運行

    spring boot項目如何采用war在tomcat容器中運行

    這篇文章主要介紹了spring boot項目如何采用war在tomcat容器中運行呢,主要講述將SpringBoot打成war包并放入tomcat中運行的方法分享,需要的朋友可以參考下
    2022-11-11

最新評論