今天在使用MyBatis执行sql语句时,出现以下异常:html
执行的sql语句配置信息以下:java
<select id="getColumnsByTableName" parameterType="String" resultType="Java.util.List">
select t.column_name from user_tab_columns t where t.tableName=#{tableName,jdbcType=VARCHAR}
</select>sql
对应的dao接口代码为:spa
public List<String> getColumnsByTableName(String tableName);.net
应该改成:xml
<select id="getColumnsByTableName" parameterType="String" resultType="String"> select t.column_name from user_tab_columns t where t.tableName=#{tableName,jdbcType=VARCHAR}</select>htm
缘由就在于resultType表明的是List中的元素类型,而不该该是List自己,究其缘由就在于被dao中的方法声明(标红出)blog
public List<String> getColumnsByTableName(String tableName);接口
给迷惑住了ip
切记:resultType返回的是集合中的元素类型,而不是集合自己