mybatis plus```
pom.xml
com.baomidou mybatis-plus-boot-starter 2.3 com.baomidou mybatis-plus 2.1.0 ```MybatisPlusConfig
import com.baomidou.mybatisplus.plugins.PaginationInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@EnableTransactionManagement
@Configuration
public class MybatisPlusConfig {
@Bean
public PaginationInterceptor paginationInterceptor() {
return new PaginationInterceptor();
}
}
yml配置
mybatis-plus:
mapper-locations: classpath*:mapper/*.xml
type-aliases-package: com.scrunfast.cqsfbh.entity
configuration:
map-underscore-to-camel-case: true
cache-enabled: false
以上基本就可以实现基本的什么 insertBatch,selectOne…
wrapper操作
查询用户名为张三的
EntityWrapper<User> ew = new EntityWrapper<>();
ew.eq("name", "张三");
User user = userService.selectOne(ew);