@@ -46,6 +46,23 @@ | |||||
</dependency> | </dependency> | ||||
<dependency> | <dependency> | ||||
<groupId>com.baomidou</groupId> | |||||
<artifactId>mybatis-plus-boot-starter</artifactId> | |||||
<version>3.1.0</version> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>p6spy</groupId> | |||||
<artifactId>p6spy</artifactId> | |||||
<version>3.8.1</version> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>mysql</groupId> | |||||
<artifactId>mysql-connector-java</artifactId> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>cn.hutool</groupId> | <groupId>cn.hutool</groupId> | ||||
<artifactId>hutool-all</artifactId> | <artifactId>hutool-all</artifactId> | ||||
</dependency> | </dependency> | ||||
@@ -1,5 +1,6 @@ | |||||
package com.xkcoding.rbac.shiro; | package com.xkcoding.rbac.shiro; | ||||
import org.mybatis.spring.annotation.MapperScan; | |||||
import org.springframework.boot.SpringApplication; | import org.springframework.boot.SpringApplication; | ||||
import org.springframework.boot.autoconfigure.SpringBootApplication; | import org.springframework.boot.autoconfigure.SpringBootApplication; | ||||
@@ -17,6 +18,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; | |||||
* @modified: yangkai.shen | * @modified: yangkai.shen | ||||
*/ | */ | ||||
@SpringBootApplication | @SpringBootApplication | ||||
@MapperScan("com.xkcoding.rbac.shiro.mapper") | |||||
public class SpringBootDemoRbacShiroApplication { | public class SpringBootDemoRbacShiroApplication { | ||||
public static void main(String[] args) { | public static void main(String[] args) { | ||||
@@ -0,0 +1,48 @@ | |||||
package com.xkcoding.rbac.shiro.config; | |||||
import com.baomidou.mybatisplus.core.parser.ISqlParser; | |||||
import com.baomidou.mybatisplus.extension.parsers.BlockAttackSqlParser; | |||||
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; | |||||
import com.baomidou.mybatisplus.extension.plugins.PerformanceInterceptor; | |||||
import org.springframework.context.annotation.Bean; | |||||
import org.springframework.context.annotation.Configuration; | |||||
import java.util.ArrayList; | |||||
import java.util.List; | |||||
/** | |||||
* <p> | |||||
* MP3 配置 | |||||
* </p> | |||||
* | |||||
* @package: com.xkcoding.rbac.shiro.config | |||||
* @description: MP3 配置 | |||||
* @author: yangkai.shen | |||||
* @date: Created in 2019-03-21 17:06 | |||||
* @copyright: Copyright (c) 2019 | |||||
* @version: V1.0 | |||||
* @modified: yangkai.shen | |||||
*/ | |||||
@Configuration | |||||
public class MybatisPlusConfig { | |||||
@Bean | |||||
public PaginationInterceptor paginationInterceptor() { | |||||
PaginationInterceptor paginationInterceptor = new PaginationInterceptor(); | |||||
List<ISqlParser> sqlParserList = new ArrayList<>(); | |||||
// 攻击 SQL 阻断解析器、加入解析链 | |||||
sqlParserList.add(new BlockAttackSqlParser()); | |||||
paginationInterceptor.setSqlParserList(sqlParserList); | |||||
return paginationInterceptor; | |||||
} | |||||
/** | |||||
* SQL执行效率插件 | |||||
*/ | |||||
@Bean | |||||
public PerformanceInterceptor performanceInterceptor() { | |||||
return new PerformanceInterceptor(); | |||||
} | |||||
} |
@@ -1,4 +1,15 @@ | |||||
server: | server: | ||||
port: 8080 | port: 8080 | ||||
servlet: | servlet: | ||||
context-path: /demo | |||||
context-path: /demo | |||||
spring: | |||||
datasource: | |||||
hikari: | |||||
username: root | |||||
password: root | |||||
driver-class-name: com.p6spy.engine.spy.P6SpyDriver | |||||
url: jdbc:p6spy:mysql://127.0.0.1:3306/spring-boot-demo?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&failOverReadOnly=false&serverTimezone=GMT%2B8 | |||||
mybatis-plus: | |||||
global-config: | |||||
# 关闭banner | |||||
banner: false |
@@ -0,0 +1,21 @@ | |||||
module.log=com.p6spy.engine.logging.P6LogFactory,com.p6spy.engine.outage.P6OutageFactory | |||||
# 自定义日志打印 | |||||
logMessageFormat=com.baomidou.mybatisplus.extension.p6spy.P6SpyLogger | |||||
#日志输出到控制台 | |||||
appender=com.baomidou.mybatisplus.extension.p6spy.StdoutLogger | |||||
# 使用日志系统记录 sql | |||||
#appender=com.p6spy.engine.spy.appender.Slf4JLogger | |||||
# 设置 p6spy driver 代理 | |||||
deregisterdrivers=true | |||||
# 取消JDBC URL前缀 | |||||
useprefix=true | |||||
# 配置记录 Log 例外,可去掉的结果集有error,info,batch,debug,statement,commit,rollback,result,resultset. | |||||
excludecategories=info,debug,result,batch,resultset | |||||
# 日期格式 | |||||
dateformat=yyyy-MM-dd HH:mm:ss | |||||
# 实际驱动可多个 | |||||
#driverlist=org.h2.Driver | |||||
# 是否开启慢SQL记录 | |||||
outagedetection=true | |||||
# 慢SQL记录标准 2 秒 | |||||
outagedetectioninterval=2 |