Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
普蓝开源社区
盘古开发框架
提交
a348197b
盘古开发框架
项目概览
普蓝开源社区
/
盘古开发框架
通知
25
Star
3
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
1
Wiki
分析
仓库
DevOps
项目成员
Pages
盘古开发框架
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
1
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a348197b
编写于
11月 26, 2021
作者:
X
xiongchun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
更新文档
上级
d0fb9292
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
40 addition
and
19 deletion
+40
-19
README.md
README.md
+7
-0
pangu-examples/pangu-examples-crud/README.md
pangu-examples/pangu-examples-crud/README.md
+32
-19
pangu-examples/pangu-examples-crud/src/main/resources/application-dev.properties
...amples-crud/src/main/resources/application-dev.properties
+1
-0
未找到文件。
README.md
浏览文件 @
a348197b
...
...
@@ -21,6 +21,13 @@
</dependency>
```
```
xml
<dependency>
<groupId>
com.gitee.pulanos.pangu
</groupId>
<artifactId>
pangu-framework-data-jdbc-spring-boot-starter
</artifactId>
</dependency>
```
### :leaves: 代码生成插件安装
```
xml
...
...
pangu-examples/pangu-examples-crud/README.md
浏览文件 @
a348197b
...
...
@@ -8,6 +8,38 @@
> :tw-1f4a3: 特别提示:经过我们对MybatisPlus框架的长期使用和总结,特给出如下2个“最佳实践”:(1)、使用盘古自带的代码成插件生成相关代码。(2)、只使用MyabtisPlus的Mapper CRUD接口,不建议使用Service CRUD接口。
#### :four_leaf_clover: 安装依赖和参数配置
-
安装依赖
```
xml
<parent>
<groupId>
com.gitee.pulanos.pangu
</groupId>
<artifactId>
pangu-framework-parent
</artifactId>
<version>
latest.version.xxx
</version>
<relativePath/>
</parent>
```
```
xml
<dependency>
<groupId>
com.gitee.pulanos.pangu
</groupId>
<artifactId>
pangu-framework-data-jdbc-spring-boot-starter
</artifactId>
</dependency>
```
-
配置参数
```
properties
spring.application.name
=
pangu-examples-crud
spring.datasource.type
=
com.zaxxer.hikari.HikariDataSource
spring.datasource.driver-class-name
=
com.mysql.cj.jdbc.Driver
spring.datasource.url
=
jdbc:mysql://localhost:3306/pangu-examples?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&failOverReadOnly=false&allowMultiQueries=true&useSSL=false
spring.datasource.username
=
root
spring.datasource.password
=
root123456
mybatis-plus.mapperLocations
=
classpath*:/mapper/**/*.xml
mybatis-plus.configuration.log-impl
=
org.apache.ibatis.logging.stdout.StdOutImpl
# 分页SQL方言数据库类型标识(缺省:自动识别)
pangu.jdbc.db-type
=
mysql
```
#### :four_leaf_clover: 如何使用盘古代码生成Maven插件生成DAO相关Mapper接口和Entity实体类
-
安装Maven插件
...
...
@@ -120,25 +152,6 @@ public int aInsert() {
-
分页查询
分页查询需要首先配置分页拦截器,如下。
```
@Configuration
public class MybatisPlusConfig {
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor();
//显式指定,免得每次都去自动获取类型
paginationInnerInterceptor.setDbType(DbType.MYSQL);
interceptor.addInnerInterceptor(paginationInnerInterceptor);
return interceptor;
}
}
```
```
public void aPageQuery(){
log.info("MyBatisPlus API 分页查询数据...");
...
...
pangu-examples/pangu-examples-crud/src/main/resources/application-dev.properties
浏览文件 @
a348197b
...
...
@@ -23,6 +23,7 @@ spring.datasource.username=root
spring.datasource.password
=
root123456
mybatis-plus.mapperLocations
=
classpath*:/mapper/**/*.xml
mybatis-plus.configuration.log-impl
=
org.apache.ibatis.logging.stdout.StdOutImpl
# 分页SQL方言数据库类型标识(缺省:自动识别)
pangu.jdbc.db-type
=
mysql
logging.level.root
=
INFO
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录