Springboot整合tkMapper

        
            tk.mybatis
            mapper-spring-boot-starter
            2.1.5
        
package com.ycz.entity;

import java.util.Date;
import java.io.Serializable;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.Table;

/**
 * (Emp)实体类
 *
 * @author makejava
 * @since 2021-12-13 15:57:42
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "emp")
public class Emp implements Serializable {
    private static final long serialVersionUID = 823718581065252741L;

    private Integer id;

    private String name;

    private String gender;

    private Double salary;
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date joinDate;

    private Integer deptId;


}

Mapper中

package com.ycz.mapper;

import com.ycz.entity.Emp;

import org.apache.ibatis.annotations.Mapper;
import tk.mybatis.mapper.common.MySqlMapper;

import java.util.List;

/**
 * (Emp)表数据库访问层
 *
 * @author makejava
 * @since 2021-12-13 15:57:41
 */
@Mapper
public interface EmpMapper extends tk.mybatis.mapper.common.Mapper, MySqlMapper {

    Emp queryById(Integer id);
}

server层

    @Override
    public Object queryAll() {
        return empMapper.selectAll();
    }

controller层

    @RequestMapping("/all")
    @ResponseBody
    public Object getAll(){
        return empService.queryAll();
    }

测试:

Springboot整合tkMapper_第1张图片

 

你可能感兴趣的:(笔记,spring,boot,eureka,java)