springboot整合Mybatis-Plus

1、导入依赖:


		<dependency>
			<groupId>com.baomidougroupId>
			<artifactId>mybatis-plus-boot-starterartifactId>
			<version>3.4.3version>
		dependency>

2、使用:
在使用MyBatis的时候,我们需要手动写SQL语句,而使用MP之后,就不需要我们手动写了。

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.southwind.springboottest.entity.Book;
import org.apache.ibatis.annotations.Mapper;
//import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
//import java.util.List;

@Mapper
@Repository
public interface BookDao extends BaseMapper<Book> {
//    @Select("select * from book where id=#{1}")
//     Book getbyid(Integer id);
//
//
//    @Select("select * from book")
//    List getall();
}

通过源码我们可以发现,BaseMapper已经封装好了相应的方法。
springboot整合Mybatis-Plus_第1张图片

你可能感兴趣的:(springboot,spring,boot,java,后端)