mybatisPlus简介

mybatisplus简化了dao层

package com.example.mp_01.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.mp_01.domain.User;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface Userdao extends BaseMapper<User> {

}

dao层中不用写一般的sql语句了

这是一个测试

package com.example.mp_01;

import com.example.mp_01.dao.Userdao;
import com.example.mp_01.domain.User;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

@SpringBootTest
class Mp01ApplicationTests {
    @Autowired(required = false)
    private Userdao userdao;
    @Test
    void testGetAll() {
        List<User> users = userdao.selectList(null);
        System.out.println(users);
    }

}
posted @ 2023-07-20 18:04  会秃头的小白  阅读(8)  评论(0编辑  收藏  举报