項目啟動發現啟動不起來,反而控制台無限輸出:Logging initialized using 'class org.apache.ibatis.logging.stdout.StdOutImpl' adapter. ,這個錯誤只有在和Spring集成的情況下才會出現。 每次只要出現這個錯誤都意味着Mybatis的存放sql操作的XML出錯了,但是具體是那個XML還沒法直接確認,因為這里的日志看不出來任何有用的信息。
- 報錯信息
Logging initialized using 'class org.apache.ibatis.logging.stdout.StdOutImpl' adapter. Registered plugin: 'com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor@3dd66ff5' Registered plugin: 'com.bzcst.bop.component.mybatis.config.MapperMethodInterceptor@24258b54' Parsed mapper file: 'file [D:\www\bop-charge\bop-charge-server\target\classes\com\bzcst\bop\charge\cal\mapper\xml\FeeCategoryMapper.xml]' Parsed mapper file: 'file [D:\www\bop-charge\bop-charge-server\target\classes\com\bzcst\bop\charge\cal\mapper\xml\FeeCategoryTemplateMapper.xml]' Parsed mapper file: 'file [D:\www\bop-charge\bop-charge-server\target\classes\com\bzcst\bop\charge\cal\mapper\xml\FeeProductMapper.xml]' Parsed mapper file: 'file [D:\www\bop-charge\bop-charge-server\target\classes\com\bzcst\bop\charge\cal\mapper\xml\FeeProductObjectMapper.xml]'
- 解決辦法
解決辦法就是定位問題,要知道是哪個mapper.xml文件出現錯誤了。我用到的就是注釋!
一般每次開發要更改的xml不多,如果剛才還能啟動正常,這回不行了,又沒有更新代碼,那就是自己的原因導致的。
就是剛才些的那些xml文件出現錯誤,就一個sql一個sql注釋掉,或者幾個sql一起注釋掉,然后啟動。直到啟動正常,說明剛才注釋的那部分代碼就是錯誤的地方,然后逐步縮小范圍。
- 一般出現這種錯誤的幾種情況
- 對應的sql語句的id有重復
- 標簽缺少,或者標簽有問題
- 中英文切換導致有特殊字符