使用逆向工程是遇到的错误

  • 错误描述
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.fei.mapper.VideoMapper.selectByExample
  • 解决办法

application.properties中增加如下配置

#============================#
#====== mybatis config ======#
#============================#
mybatis.type-aliases-package=com.fei.domain
mybatis.mapper-locations=classpath:mapper/*.xml # open camel rule mapping
mybatis.configuration.map-underscore-to-camel-case=true
# show sql statement in console
mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl

使用Mybatis注解开发增删改查

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update; public interface VideoMapper {
/**
* 自己写的方法,使用// mapper接口扫描@MapperScan("com.fei.mapper")
*
* @return
*/
@Select("select * from video")
@Results({
// 结果集映射规则,自己编写接口方法时需要指定,若使用逆向工程自动生成的方法则不需要指定
// column对应数据库表字段,property对应Java对象属性
// 但是这种方法,假如数据库表字段很多会很麻烦,所以可以在application.properties配置文件中开启驼峰映射规则
// mybatis.configuration.map-underscore-to-camel-case=true
@Result(column = "create_time", property = "createTime"),
@Result(column = "cover_img", property = "coverImg"), @Result(column = "view_num", property = "viewNum") })
List<Video> findAll(); @Select("select * from video where id = #{id}")
Video findById(int id); @Update("update video set title = #{title} where id = #{id}")
int update(Video video); @Delete("delete from video where id = #{id}")
int delete(int id); @Insert("insert into video (title, summary, cover_img, view_num, price, create_time, online, point) "
+ " values (#{title}, #{summary}, #{coverImg}, #{viewNum}, #{price}, #{createTime}, #{online}, #{point})")
// 获取自增id
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
int save(Video video);
}

Spring Boot 使用Mybatis注解开发增删改查的更多相关文章

  1. spring boot整合mybatis框架及增删改查(jsp视图)

    工具:idea.SQLyog 版本:springboot1.5.9版本.mysql5.1.62 第一步:新建项目 第二步:整合依赖(pom.xml) <dependencies> < ...

  2. MyBatis -- 对表进行增删改查(基于注解的实现)

    1.MyBatis对数据库表进行增/删/改/查 前一篇使用基于XML的方式实现对数据库的增/删/改/查 以下我们来看怎么使用注解的方式实现对数据库表的增/删/改/查 1.1  首先须要定义映射sql的 ...

  3. Mybatis_3.基于注解的增删改查

    1.实体类User.java public class User { private int id; private String name; private int age; //getter.se ...

  4. Mybatis入门之增删改查

    Mybatis入门之增删改查 Mybatis如果操作成功,但是数据库没有更新那就是得添加事务了.(增删改都要添加)----- 浪费了我40多分钟怀疑人生后来去百度... 导入包: 引入配置文件: sq ...

  5. mybatis中的增删改查操作

    在这一个部分,主要进行增删改查的示例书写. 增删改查可以基于xml的,也可以基于注解的方式. 一:对单条数据的查询 1.目录结构 这个使得目录更加清晰 2.User.java 这个使用以前的user表 ...

  6. Mybatis实现简单增删改查

    Mybatis的简单应用 学习内容: 需求 环境准备 代码 总结: 学习内容: 需求 使用Mybatis实现简单增删改查(以下是在IDEA中实现的,其他开发工具中,代码一样) jar 包下载:http ...

  7. MyBatis简单的增删改查以及简单的分页查询实现

    MyBatis简单的增删改查以及简单的分页查询实现 <? xml version="1.0" encoding="UTF-8"? > <!DO ...

  8. Ecmall二次开发-增删改查操作

    Ecmall二次开发-增删改查操作 Model目录includes/models 自己添加需要的model class OrdercomplainModel extends BaseModel //类 ...

  9. Spring Boot 知识笔记(整合Mybatis续-补充增删改查)

    续上篇,补充数据库增删改查的其他场景. 一.Mapper中添加其他场景操作 package net.Eleven.demo.Mapper; import net.Eleven.demo.domain. ...

随机推荐

  1. 十五、RF操作时间控件

    由于日期控件经常用的是readonly属性,这个属性意思是此控件为可读,明白点就是只让你看,不让你动. 解决方法就是:用js去掉这个属性,就可写了,就能输入了 导入库:DateTime #方式一 op ...

  2. Stream介绍

    一.Stream介绍 现在有这样的需求:有个菜单list,菜单里面非常多的食物列表,只选取小于400卡路里的并且按照卡路里排序,然后只想知道对应的食物名字. 代码: package com.cy.ja ...

  3. 【疑难杂症】Firefox 火狐浏览器 抓不到本地数据包

    日期:2019-05-17 23:28:11 介绍:火狐浏览器,如何才能够抓到本地(127.0.0.1)的数据包? 0x01.问题描述 在 Firefox 上安装了证书,浏览器也可以正常抓取互联网的 ...

  4. Unity3D(C#)连接SQL Server2008

    首先部署安装sql server2008,添加Sql Manager. Unity3D连接需要在Unity2017\Editor\Data\Mono\lib\mono\unity文件下找到4个头文件l ...

  5. 编写shell脚本一键启动 重启 停止springboot项目

    #!/bin/bash #设置环境变量 export JAVA_HOME=/usr/local/jdk1.8.0_181 export JRE_HOME=/$JAVA_HOME/jre export ...

  6. C# DES 加解密

    using System; using System.Text; using System.Security.Cryptography; using System.Diagnostics; using ...

  7. bigdata数据分析(二):关闭防火墙&安装telnet

    先检查CentOS7.0是否已经安装以下两个安装包:telnet-server.xinetd.命令如下: rpm -qa telnet-server rpm -qa xinetd 如果没有安装,则先安 ...

  8. kafak学习(一)

    发布与订阅消息系统. 数据(消息)的发送者不会直接把消息发送给接受者,这是发布与订阅消息系统的一个特点.发布者以某种方式对消息进行分类,接受者订阅他们,以便接受特定类型的消息.发布与订阅系统一般会有一 ...

  9. 一个简单的dns服务器

    options { listen-on port 53 { any; }; listen-on-v6 port 53 { any; }; directory "/srv/app/named& ...

  10. Mongodb-安全配置优化

    1.MongoDB配置文件样例 # mongod.conf, Percona Server for MongoDB # for documentation of all options, see: # ...