Skip to content

Latest commit

 

History

History
50 lines (31 loc) · 949 Bytes

README.md

File metadata and controls

50 lines (31 loc) · 949 Bytes

Dynamic Mapper

运行时动态生成 ServiceImplBaseMapper,基于 Mybatis-plus

根据数据库实体创建,不会重复创建已经定义的 ServiceMapper

具体效果


使用步骤


定义一个 @TableName 修饰的数据库实体

import com.baomidou.mybatisplus.annotation.TableName;

@TableName
public class Foo {
}

使用

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.entity.Foo;

import javax.annotation.Resource;

public class Test {

    @Resource
    private BaseMapper<Foo> fooMapper;

    @Resource
    private ServiceImpl<BaseMapper<Foo>, Foo> fooService;

    public void test() {
        fooMapper.selectList(null);
        fooService.lambdaQuery().list();
    }
}