亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

mybatis和mybatis-plus同時(shí)使用的坑

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

原項(xiàng)目基于mybatis開(kāi)發(fā),新功能基于mybatis-plus開(kāi)發(fā),同時(shí)依賴如下兩個(gè)jar包

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

啟動(dòng)時(shí)報(bào)錯(cuò):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)

啟動(dòng)后錯(cuò)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同時(shí)使用的坑的文章就介紹到這了,更多相關(guān)mybatis和mybatis-plus同時(shí)使用內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

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

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

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

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

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

    Java設(shè)計(jì)模式之抽象工廠模式簡(jiǎn)析

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

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

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

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

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

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

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

    5個(gè)步驟讓你明白多線程和線程安全

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

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

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

    2020年IntelliJ IDEA最新最詳細(xì)配置圖文教程詳解

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

    spring boot項(xiàng)目如何采用war在tomcat容器中運(yùn)行

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

最新評(píng)論