Skip to content

Dynamic mapper without actual java mapper file, base on mybatis-plus.

Notifications You must be signed in to change notification settings

wolfiesonfire/dynamic-mapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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();
    }
}

About

Dynamic mapper without actual java mapper file, base on mybatis-plus.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages