Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita6dfb84

Browse files
committed
MyBatis Plus demo
1 parent6a1e488 commita6dfb84

File tree

12 files changed

+262
-0
lines changed

12 files changed

+262
-0
lines changed

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Spring Boot 使用的各种示例,以最简单、最实用为标准,此开
3333
-[spring-boot-webflux](https://github.com/ityouknow/spring-boot-examples/tree/master/spring-boot-webflux) :Spring Boot webflux 示例
3434
-[spring-boot-elasticsearch](https://github.com/ityouknow/spring-boot-examples/tree/master/spring-boot-elasticsearch) :Spring Boot elasticsearch 示例
3535
-[spring-boot-swagger](https://github.com/ityouknow/spring-boot-examples/tree/master/spring-boot-swagger) :Spring Boot swagger2 示例
36+
-[spring-boot-mybatis-plus](https://github.com/ityouknow/spring-boot-examples/tree/master/spring-boot-mybatis-plus) :Spring Boot 集成 MyBatis Plus 示例
3637

3738
**参考文章**
3839

‎README_EN.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ Spring Boot examples, using the simplest and the most useful scene demos.
2323
-[spring-boot-webflux](https://github.com/ityouknow/spring-boot-examples/tree/master/spring-boot-webflux) :Spring Boot webflux demo
2424
-[spring-boot-elasticsearch](https://github.com/ityouknow/spring-boot-examples/tree/master/spring-boot-elasticsearch) :Spring Boot elasticsearch demo
2525
-[spring-boot-swagger](https://github.com/ityouknow/spring-boot-examples/tree/master/spring-boot-swagger) :Spring Boot swagger2 demo
26+
-[spring-boot-mybatis-plus](https://github.com/ityouknow/spring-boot-examples/tree/master/spring-boot-mybatis-plus) :Spring Boot MyBatis Plus demo
27+
28+
2629
---
2730

2831
##Spring Boot (Already upgraded to 2.x)

‎spring-boot-mybatis-plus/pom.xml‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>com.example</groupId>
7+
<artifactId>spring-boot-mybatis-plus</artifactId>
8+
<version>1.0.0</version>
9+
<packaging>jar</packaging>
10+
11+
<name>Spring Boot MyBatis Plus</name>
12+
<description>Spring Boot 2 Demo</description>
13+
14+
<parent>
15+
<groupId>org.springframework.boot</groupId>
16+
<artifactId>spring-boot-starter-parent</artifactId>
17+
<version>2.1.4.RELEASE</version>
18+
</parent>
19+
20+
<properties>
21+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
22+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
23+
<java.version>1.8</java.version>
24+
</properties>
25+
26+
<dependencies>
27+
<dependency>
28+
<groupId>org.projectlombok</groupId>
29+
<artifactId>lombok</artifactId>
30+
<optional>true</optional>
31+
</dependency>
32+
<dependency>
33+
<groupId>com.baomidou</groupId>
34+
<artifactId>mybatis-plus-boot-starter</artifactId>
35+
<version>3.1.1</version>
36+
</dependency>
37+
<dependency>
38+
<groupId>com.h2database</groupId>
39+
<artifactId>h2</artifactId>
40+
<scope>runtime</scope>
41+
</dependency>
42+
<dependency>
43+
<groupId>org.springframework.boot</groupId>
44+
<artifactId>spring-boot-starter-test</artifactId>
45+
<scope>test</scope>
46+
</dependency>
47+
</dependencies>
48+
49+
<build>
50+
<plugins>
51+
<plugin>
52+
<groupId>org.springframework.boot</groupId>
53+
<artifactId>spring-boot-maven-plugin</artifactId>
54+
</plugin>
55+
</plugins>
56+
</build>
57+
58+
</project>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
packagecom.neo;
2+
3+
importorg.springframework.boot.SpringApplication;
4+
importorg.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
@SpringBootApplication
7+
publicclassMyBatisPlusApplication {
8+
9+
publicstaticvoidmain(String[]args) {
10+
SpringApplication.run(MyBatisPlusApplication.class,args);
11+
}
12+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
packagecom.neo.config;
2+
3+
importcom.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
4+
importorg.mybatis.spring.annotation.MapperScan;
5+
importorg.springframework.context.annotation.Bean;
6+
importorg.springframework.context.annotation.Configuration;
7+
8+
@Configuration
9+
@MapperScan("com.neo.mapper")
10+
publicclassMybatisPlusConfig {
11+
12+
/**
13+
* 分页插件
14+
*/
15+
@Bean
16+
publicPaginationInterceptorpaginationInterceptor() {
17+
returnnewPaginationInterceptor();
18+
}
19+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
packagecom.neo.mapper;
2+
3+
importcom.baomidou.mybatisplus.core.mapper.BaseMapper;
4+
importcom.neo.model.User;
5+
6+
publicinterfaceUserMapperextendsBaseMapper<User> {
7+
8+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
packagecom.neo.model;
2+
3+
importlombok.Data;
4+
5+
@Data
6+
publicclassUser {
7+
privateLongid;
8+
privateStringname;
9+
privateIntegerage;
10+
privateStringemail;
11+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# DataSource Config
2+
spring:
3+
datasource:
4+
driver-class-name:org.h2.Driver
5+
schema:classpath:db/schema-h2.sql
6+
data:classpath:db/data-h2.sql
7+
url:jdbc:h2:mem:test
8+
username:root
9+
password:test
10+
11+
# Logger Config
12+
logging:
13+
level:
14+
com.neo:debug
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
DELETEFROM user;
2+
3+
INSERT INTO user (id, name, age, email)VALUES
4+
(1,'neo',18,'smile1@ityouknow.com'),
5+
(2,'keep',36,'smile@ityouknow.com'),
6+
(3,'pure',28,'smile@ityouknow.com'),
7+
(4,'smile',21,'smile@ityouknow.com'),
8+
(5,'it',24,'smile@ityouknow.com');
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
DROPTABLE IF EXISTS user;
2+
3+
CREATETABLEuser
4+
(
5+
idBIGINT(20)NOT NULL COMMENT'主键ID',
6+
nameVARCHAR(30)NULL DEFAULTNULL COMMENT'姓名',
7+
ageINT(11)NULL DEFAULTNULL COMMENT'年龄',
8+
emailVARCHAR(50)NULL DEFAULTNULL COMMENT'邮箱',
9+
PRIMARY KEY (id)
10+
);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp