文章目录
一、前言
Springboot集成tk.Mybatis,集成后对于简单的增删改查,可以快速上手节省时间。记录集成过程,方便后期使用。
1.目录
2.User实体类
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
/**
* @Author: gjc
* @createTime: 2022年07月13日 19:46:44
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "shiro_user")
public class User implements Serializable {
@Id
private Integer user_id;
@Column(name = "user_name")
private String username;
@Column(name = "password")
private String password;
}
3.UserMapper的dao层类
import com.renjie.entity.User;
import tk.mybatis.mapper.common.Mapper;
/**
* @Author: gjc
* @createTime: 2022年07月13日 19:52:38
*/
@org.apache.ibatis.annotations.Mapper
public interface UserMapper extends Mapper<User> {
}
4.UserServiceImpl实现类
import com.renjie.entity.User;
import com.renjie.mapper.UserMapper;
import com.renjie.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;
import java.util.List;
/**
* @Author: gjc
* @createTime: 2022年07月13日 19:55:58
*/
@Service
public class UserServiceImpl implements UserService {
@Autowired
private UserMapper userMapper;
@Override
public List<User> queryUserInfo(String username) {