解決Type interface com.kuang.mapper.UserMapper is not known to the MapperRegistry.的問題


解決Type interface com.kuang.mapper.UserMapper is not known to the MapperRegistry.的問題

錯誤代碼:

二月 13, 2022 7:43:04 下午 org.springframework.jdbc.datasource.DriverManagerDataSource setDriverClassName
信息: Loaded JDBC driver: com.mysql.cj.jdbc.Driver
二月 13, 2022 7:43:05 下午 org.apache.ibatis.logging.commons.JakartaCommonsLoggingImpl warn
警告: Property 'mapperLocations' was specified but matching resources are not found.
Exception in thread "main" org.apache.ibatis.binding.BindingException: Type interface com.kuang.mapper.UserMapper is not known to the MapperRegistry.
    at org.apache.ibatis.binding.MapperRegistry.getMapper(MapperRegistry.java:47)
    at org.apache.ibatis.session.Configuration.getMapper(Configuration.java:779)
    at org.mybatis.spring.SqlSessionTemplate.getMapper(SqlSessionTemplate.java:311)
    at com.kuang.mapper.UserMapperImpl.selectUser(UserMapperImpl.java:19)
    at MyTest.main(MyTest.java:10)

 

經過檢查發現,target中未生成 UserMapper.xml文件。

 

 

 

暫時的解決辦法是把以前文件中的 target -->classes-->com-->kuang-->mapper中的UserMapper.xml文件復制下來,粘貼到現在那個文件的target同樣位置中,非常的治標不治本。

或者重新創建一個項目,編寫同樣的代碼。感覺可能是創建項目的時候idea出錯的問題。

 

 

 

暫未找到解決方法

看了四個小時屬實是心態崩了,記錄下來等level更高之后再嘗試解決。

路徑:spring-study  -->  spring-12-transaction

 
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM