mybatis注解方式批量插入数据

时间:2023-01-29 18:13:03
@Insert("<script>"  +
            "INSERT INTO cms_portal_menu(name,service_type,index_code) VALUES" +
            "<foreach collection=\"list\" item=\"item1\" index=\"index\"  separator=\",\">" +
            "(#{item1.name},#{item1.serviceType},#{item1.indexCode})" +
            "</foreach>" +
            "</script>")
    int batchInsert(@Param("list")List<Menu> menus);

注意别漏掉script标签