在dao中这样写的:
@Select({ "select", "id, item_id, title, source, category_id, category_name, recommend_id, images, dynamic_picture, ", "source_images, create_time, type_name, summary, tag, api, url, load_type, md5, is_pushed, is_to_push, ", "to_push_time", "from bb_news_list", "where source = #{source,jdbcType=VARCHAR} and dynamic_picture is not NULL ORDER BY RAND() LIMIT #{num,jdbcType=INTEGER} " }) @Results({ @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true), @Result(column="item_id", property="itemId", jdbcType=JdbcType.VARCHAR), @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR), @Result(column="source", property="source", jdbcType=JdbcType.VARCHAR), @Result(column="category_id", property="categoryId", jdbcType=JdbcType.VARCHAR), @Result(column="category_name", property="categoryName", jdbcType=JdbcType.VARCHAR), @Result(column="recommend_id", property="recommendId", jdbcType=JdbcType.VARCHAR), @Result(column="images", property="images", jdbcType=JdbcType.VARCHAR), @Result(column="dynamic_picture", property="dynamic_picture", jdbcType=JdbcType.VARCHAR), @Result(column="source_images", property="source_images", jdbcType=JdbcType.VARCHAR), @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="type_name", property="typeName", jdbcType=JdbcType.VARCHAR), @Result(column="summary", property="summary", jdbcType=JdbcType.VARCHAR), @Result(column="tag", property="tag", jdbcType=JdbcType.VARCHAR), @Result(column="api", property="api", jdbcType=JdbcType.VARCHAR), @Result(column="url", property="url", jdbcType=JdbcType.VARCHAR), @Result(column="load_type", property="loadType", jdbcType=JdbcType.VARCHAR), @Result(column="md5", property="md5", jdbcType=JdbcType.VARCHAR), @Result(column="is_pushed", property="isPushed", jdbcType=JdbcType.INTEGER), @Result(column="is_to_push", property="isToPush", jdbcType=JdbcType.INTEGER), @Result(column="to_push_time", property="toPushTime", jdbcType=JdbcType.TIMESTAMP) }) List<BbNewsList> queryListBySource(String source,int num);
运行后会报错Parameter 'source' not found. Available parameters are [0, 1, param1, param2]
只要将List<BbNewsList> queryListBySource(String source,int num);改为
List<BbNewsList> queryListBySource( @Param("source")String source,@Param("num")int num);就好了