springboot集成通用mapper

请耐心看下去
pom.xml

//不要它
<!-- <dependency>
			<groupId>org.mybatis.spring.boot</groupId>
			<artifactId>mybatis-spring-boot-starter</artifactId>
			<version>2.0.0</version>
		</dependency> -->
		
        <!-- mapper4 -->
		<dependency>
		    <groupId>tk.mybatis</groupId>
		    <artifactId>mapper-spring-boot-starter</artifactId>
		    <version>2.0.2</version>
		</dependency>

在启动类上注解在这里插入图片描述在工具包建一个BaseMapper 调用StatisticalMapper 实现基本CRUD

package com.zl.utils;
import org.springframework.stereotype.Component;
 
import tk.mybatis.mapper.common.Mapper;
import tk.mybatis.mapper.common.MySqlMapper;
 
@Component
public interface BaseMapper<T> extends Mapper<T>, MySqlMapper<T> {
 
}
写一个Mapper继承BaseMapper
package com.zl.dao;

import java.util.List;

import org.apache.ibatis.annotations.Select;

import com.zl.enity.Statistical;
import com.zl.utils.BaseMapper;

public interface StatisticalMapper extends BaseMapper<Statistical>{
    
	
}


再enity中

猜你喜欢

转载自blog.csdn.net/weixin_43887789/article/details/90699672