sprintboot+mybatis+@Mapper中in的使用方法
错误的使用方法:
@Select("select goods_sn from ${tableName} where goods_sn in (#{skuStr})") public List<String> selectForAlgorithm(@Param("skuStr") String skuStr,@Param("tableName") String tableName);
正确的使用方法:
@SelectProvider(type = DWebsiteProvider.class,method="selectForAlgorithm") public List<String> selectForAlgorithm(@Param("skuStr") String skuStr,@Param("tableName") String tableName);
之后在DWebsiteProvider类中添加如下方法:
public String selectForAlgorithm(String skuStr,String tableName){ StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("select goods_sn from "+tableName+" where goods_sn in ("+skuStr+");"); return stringBuilder.toString(); }