A query was run and no Result Maps were found for...原來是mapper.xml檔案出了問題,是使用MyBatis最常見的一種錯誤

來源:互聯網
上載者:User

標籤:except   font   dstat   技術分享   apach   get   exe   span   查詢語句   

今天遇到一個問題,原來是mapper.xml檔案出了問題,是使用MyBatis最常見的一種錯誤

 

報錯的結果是這樣的:

 A query was run and no Result Maps were found for the Mapped Statement ‘cn.zrgk.dao.RoleMapper.getRoleList‘.  

  It‘s likely that neither a Result Type nor a Result Map was specified.
org.apache.ibatis.executor.ExecutorException: A query was run and no Result Maps were found for the Mapped Statement ‘cn.zrgk.dao.RoleMapper.getRoleList‘. 
   It‘s likely that neither a Result Type nor a Result Map was specified. org.apache.ibatis.executor.resultset.FastResultSetHandler.validateResultMapsCount(FastResultSetHandler.java:177) org.apache.ibatis.executor.resultset.FastResultSetHandler.handleResultSets(FastResultSetHandler.java:150) org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:57) org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:70) org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:57) org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:259) org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:132) org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:105) org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:81) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:606)

我的mapper.xml檔案中有個查詢語句是這樣寫的:

   大家看看圖一,好像根本沒有錯誤,對嗎?再看看

 

  是的,沒錯,我沒有指定這個方法的傳回型別,系統無法識別,於是就這樣改了一下,發現不報錯了

 

 

所以平時啊,我們要多多注意這些細節,更要去多加理解

 

A query was run and no Result Maps were found for...原來是mapper.xml檔案出了問題,是使用MyBatis最常見的一種錯誤

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.