- 测试后分析打印的sql语句,将version的数值进行了加1操作。 | package com.wzy.bootmtp.test;
import com.wzy.bootmtp.mapper.UserMapper;
import com.wzy.bootmtp.pojo.User;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.List;
@RunWith(SpringRunner.class)
@SpringBootTest
public class TestSpringBoot {
@Autowired<br /> **private **UserMapper **userMapper**;
@Test<br /> **public void **test1(){<br /> //查询<br /> User user = **userMapper**.selectById(1L);<br /> //修改数据<br /> user.setName(**"你好"**);<br /> user.setEmail(**"hello@qq.com"**);<br /> //执行更新<br /> **userMapper**.updateById(user);<br /> }<br />}
| | —- |