标签:seq 代码 通用操作 查询条件 通用 source mysq sql spring
MyBatis-Plus(简称 MP)是一个 MyBatis 的增强工具,在 MyBatis 的基础上只做增强不做改变,为简化开发繁琐的CRUD、提高代码效率而生,同时提供了代码生成器和分页插件,支持Spring boot,spring mvc开发。
? 特性
支持数据库
框架结构
添加pom.xml依赖
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.1.RELEASE</version>
<relativePath/>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.0</version>
</dependency>
<!-- 提供mysql驱动 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
</dependencies>
配置application.yml
server:
port: 80
spring:
application:
name: mp
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.jdbc.driver
url: jdbc:mysql://localhost:3306/mp?autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true
username: root
password: 1234
mybatis-plus:
mapper-locations:classpath: mapper/*Mapper.xml
type-aliases-package: com.mp.entity
创建启动类MpApplication.java
@EnableTransactionManagement
@SpringBootApplication
@MapperScan("com.yiyang.mapper")
public class MpApplication {
public static void main(String[] args) {
SpringApplication.run(MpApplication.class, args);
}
}
创建实体类
@Data
@TableName("user")
public class User {
@TableId(type=IdType.INPUT)
private Long id;
@TableField
private String name;
@TableField
private Integer age;
@TableField
private String email;
/**...setter,getter......*/
}
运行就Ok了
标签:seq 代码 通用操作 查询条件 通用 source mysq sql spring
原文地址:https://www.cnblogs.com/yiyangyu/p/xiaotang.html