From 43969cfce88444a37b35e95b6826d89514fdbd41 Mon Sep 17 00:00:00 2001 From: EasternUnbeaten Date: Thu, 5 Mar 2020 14:34:17 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E5=B7=A5=E7=A8=8B=E4=BB=A3=E7=A0=81=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 33 +++++- src/main/assembly/assembly.xml | 5 +- .../springboot/assembly/Application.java | 2 + .../springboot/assembly/entity/AppDemo.java | 20 ++++ .../assembly/mapper/AppDemoMapper.java | 12 ++ .../assembly/service/AppDemoService.java | 13 +++ .../service/impl/AppDemoServiceImpl.java | 25 ++++ .../assembly/web/AppUserController.java | 33 ++++++ src/main/resources/application-prod.yml | 16 +++ src/main/resources/application.yml | 107 +++++++++++++++++- .../resources/mapper/demo/AppDemoMapper.xml | 7 ++ src/main/resources/mapper/hello/hello.xml | 4 - src/main/resources/mapper/test.xml | 4 - 13 files changed, 270 insertions(+), 11 deletions(-) create mode 100644 src/main/java/io/geekidea/springboot/assembly/entity/AppDemo.java create mode 100644 src/main/java/io/geekidea/springboot/assembly/mapper/AppDemoMapper.java create mode 100644 src/main/java/io/geekidea/springboot/assembly/service/AppDemoService.java create mode 100644 src/main/java/io/geekidea/springboot/assembly/service/impl/AppDemoServiceImpl.java create mode 100644 src/main/java/io/geekidea/springboot/assembly/web/AppUserController.java create mode 100644 src/main/resources/mapper/demo/AppDemoMapper.xml delete mode 100644 src/main/resources/mapper/hello/hello.xml delete mode 100644 src/main/resources/mapper/test.xml diff --git a/pom.xml b/pom.xml index c40f6c2..5a92923 100644 --- a/pom.xml +++ b/pom.xml @@ -38,9 +38,34 @@ UTF-8 UTF-8 1.8 + 1.1.21 + 8.0.18 + 3.3.1 + + org.projectlombok + lombok + provided + + + com.alibaba + druid-spring-boot-starter + ${druid.version} + + + + com.baomidou + mybatis-plus-boot-starter + ${mybatis-plus.version} + + + + mysql + mysql-connector-java + ${mysql.version} + org.springframework.boot spring-boot-starter-web @@ -75,10 +100,13 @@ src/main/resources true + + mapper/**/*.xml + application.yml application-${profileActive}.yml - mapper/**/*.xml + static/** templates/** *.xml @@ -102,6 +130,9 @@ ../lib true + + resources/ + diff --git a/src/main/assembly/assembly.xml b/src/main/assembly/assembly.xml index be33196..9be7de1 100644 --- a/src/main/assembly/assembly.xml +++ b/src/main/assembly/assembly.xml @@ -34,10 +34,13 @@ ${basedir}/target/classes config 0644 + + mapper/**/*.xml + application.yml application-${profileActive}.yml - mapper/**/*.xml + static/** templates/** *.xml diff --git a/src/main/java/io/geekidea/springboot/assembly/Application.java b/src/main/java/io/geekidea/springboot/assembly/Application.java index 430adbe..0fd3595 100644 --- a/src/main/java/io/geekidea/springboot/assembly/Application.java +++ b/src/main/java/io/geekidea/springboot/assembly/Application.java @@ -1,5 +1,6 @@ package io.geekidea.springboot.assembly; +import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ConfigurableApplicationContext; @@ -11,6 +12,7 @@ import org.springframework.core.env.ConfigurableEnvironment; * @since 2018/11/20 */ @SpringBootApplication +@MapperScan("io.geekidea.springboot.assembly.mapper") public class Application { public static void main(String[] args) { diff --git a/src/main/java/io/geekidea/springboot/assembly/entity/AppDemo.java b/src/main/java/io/geekidea/springboot/assembly/entity/AppDemo.java new file mode 100644 index 0000000..1aa95a8 --- /dev/null +++ b/src/main/java/io/geekidea/springboot/assembly/entity/AppDemo.java @@ -0,0 +1,20 @@ +package io.geekidea.springboot.assembly.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.time.LocalDateTime; + +/** + * @author Eastern unbeaten + * @email chenshiyun2011@163.com + * @data 2019-06-22 + */ +@Data +@TableName("APP_DEMO") +public class AppDemo { + + private String id; + private String name; + private LocalDateTime createTime; +} diff --git a/src/main/java/io/geekidea/springboot/assembly/mapper/AppDemoMapper.java b/src/main/java/io/geekidea/springboot/assembly/mapper/AppDemoMapper.java new file mode 100644 index 0000000..a629383 --- /dev/null +++ b/src/main/java/io/geekidea/springboot/assembly/mapper/AppDemoMapper.java @@ -0,0 +1,12 @@ +package io.geekidea.springboot.assembly.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import io.geekidea.springboot.assembly.entity.AppDemo; + +import java.util.List; + + +public interface AppDemoMapper extends BaseMapper { + + List getxx(); +} diff --git a/src/main/java/io/geekidea/springboot/assembly/service/AppDemoService.java b/src/main/java/io/geekidea/springboot/assembly/service/AppDemoService.java new file mode 100644 index 0000000..075d742 --- /dev/null +++ b/src/main/java/io/geekidea/springboot/assembly/service/AppDemoService.java @@ -0,0 +1,13 @@ +package io.geekidea.springboot.assembly.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import io.geekidea.springboot.assembly.entity.AppDemo; + +import java.util.List; + + +public interface AppDemoService extends IService { + + List getxx(); + +} diff --git a/src/main/java/io/geekidea/springboot/assembly/service/impl/AppDemoServiceImpl.java b/src/main/java/io/geekidea/springboot/assembly/service/impl/AppDemoServiceImpl.java new file mode 100644 index 0000000..f397f4b --- /dev/null +++ b/src/main/java/io/geekidea/springboot/assembly/service/impl/AppDemoServiceImpl.java @@ -0,0 +1,25 @@ +package io.geekidea.springboot.assembly.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; + +import io.geekidea.springboot.assembly.entity.AppDemo; +import io.geekidea.springboot.assembly.mapper.AppDemoMapper; +import io.geekidea.springboot.assembly.service.AppDemoService; +import org.springframework.beans.factory.annotation.Autowired; + import org.springframework.stereotype.Service; + +import java.util.List; + + +@Service +public class AppDemoServiceImpl extends ServiceImpl implements AppDemoService { + + @Autowired + private AppDemoMapper appDemoMapper; + + + @Override + public List getxx() { + return appDemoMapper.getxx(); + } +} diff --git a/src/main/java/io/geekidea/springboot/assembly/web/AppUserController.java b/src/main/java/io/geekidea/springboot/assembly/web/AppUserController.java new file mode 100644 index 0000000..433c9cc --- /dev/null +++ b/src/main/java/io/geekidea/springboot/assembly/web/AppUserController.java @@ -0,0 +1,33 @@ +package io.geekidea.springboot.assembly.web; + + +import io.geekidea.springboot.assembly.service.AppDemoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + + +@RestController +@RequestMapping("/demo") +public class AppUserController { + + + @Autowired + private AppDemoService appDemoService; + + @GetMapping(value = "/list") + public ResponseEntity list() { + return ResponseEntity.ok(appDemoService.getxx()); + } + + + @GetMapping(value = "/list2") + public ResponseEntity list2() { + return ResponseEntity.ok(appDemoService.list()); + } + + + +} diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index e69de29..1bc844e 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -0,0 +1,16 @@ +#druid sql 监控异常抛出配置 生产的时候异常就要抛出,测试环境,只要打印出来就行 +# 刚开始引入WallFilter的时候,把logViolation设置为true,而throwException设置为false。就可以观察是否存在违规的情况,同时不影响业务运行。 +#对被认为是攻击的SQL进行LOG.error输出 +druid-log-violation: false +#对被认为是攻击的SQL抛出SQLException +druid-throw-exception: true +datasource: + mysql: + validation-query: select 1 + driver: com.mysql.cj.jdbc.Driver + database: test + ip: 127.0.0.1 + port: 3306 + username: root + password: 123456 + url: jdbc:mysql://${datasource.mysql.ip}:${datasource.mysql.port}/${datasource.mysql.database}?useSSL=false&serverTimezone=UTC&characterEncoding=utf8 \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 3f61065..0825776 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,3 +1,13 @@ +#配置sql监控的,你是什么数据库就写什么 mysql,mysql,sqlserver +druid-sql-type: mysql +#druid监控打开, stat-view stat,wall 全部引用到了,火力全开 +druid-enabled: true +#druid sql 监控异常抛出配置 生产的时候异常就要抛出,测试环境,只要打印出来就行 +# 刚开始引入WallFilter的时候,把logViolation设置为true,而throwException设置为false。就可以观察是否存在违规的情况,同时不影响业务运行。 +#对被认为是攻击的SQL进行LOG.error输出 +druid-log-violation: true +#对被认为是攻击的SQL抛出SQLException +druid-throw-exception: false server: servlet: context-path: /example @@ -9,5 +19,100 @@ spring: # 当前maven打包的profile profiles: active: @profileActive@ - + datasource: + druid: + stat-view-servlet: + loginUsername: ${datasource.druid.login-username} + loginPassword: ${datasource.druid.login-password} + enabled: ${druid-enabled} + #白名单IP白名单 (没有配置或者为空,则允许所有访问) + # allow: + #IP黑名单 (存在共同时,deny优先于allow) + # deny: + # url-pattern: /druid/* + min-idle: 5 + max-active: 10 + initial-size: 1 + validation-query-timeout: 1 + #申请连接时执行validationQuery检测连接是否有效 + test-on-borrow: false + #归还连接时执行validationQuery检测连接是否有效 + test-on-return: false + #申请连接的时候检测,如果空闲时间大于timeBetweenEvictionRunsMillis,执行validationQuery检测连接是否有效。 + test-while-idle: true + # 获取连接时最大等待时间,单位毫秒。配置了maxWait之后,缺省启用公平锁,并发效率会有所下降,如果需要可以通过配置useUnfairLock属性为true使用非公平锁。 + max-wait: 30000 + # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 + time-between-eviction-runs-millis: 2000 + #连接保持空闲而不被驱逐的最小时间,单位是毫秒 + min-evictable-idle-time-millis: 600000 + max-evictable-idle-time-millis: 900000 + filter: + # https://github.com/alibaba/druid/wiki/%E9%85%8D%E7%BD%AE-wallfilter + stat: + db-type: ${druid-sql-type} + log-slow-sql: true + #2秒算慢sql + slow-sql-millis: 2000 + merge-sql: true + enabled: ${druid-enabled} + wall: + db-type: ${druid-sql-type} + config: + # 是否允许非以上基本语句的其他语句,缺省关闭,通过这个选项就能够屏蔽DDL。 + none-base-statement-allow: true + # 检查DELETE语句是否无where条件,这是有风险的,但不是SQL注入类型的风险 + delete-where-none-check: true + # 检查UPDATE语句是否无where条件,这是有风险的,但不是SQL注入类型的风险 + update-where-none-check: true + #是否允许 truncate语句 + truncate-allow: false + #是否允许drop表 + drop-table-allow: false + # 刚开始引入WallFilter的时候,把logViolation设置为true,而throwException设置为false。就可以观察是否存在违规的情况,同时不影响业务运行。 + #对被认为是攻击的SQL进行LOG.error输出 + log-violation: ${druid-log-violation} + #对被认为是攻击的SQL抛出SQLException + throw-exception: ${druid-throw-exception} + #是否开启过滤器 + enabled: ${druid-enabled} + filters: stat,wall + # 用来检测连接是否有效的sql,要求是一个查询语句。如果validationQuery为null,testOnBorrow、testOnReturn、testWhileIdle都不会其作用。 + validation-query: ${datasource.mysql.validation-query} + driver-class-name: ${datasource.mysql.driver} + username: ${datasource.mysql.username} + password: ${datasource.mysql.password} + url: ${datasource.mysql.url} + # + keep-alive: true + phy-max-use-count: 500 + #异步关闭链接启用 + async-init: true + async-close-connection-enable: true hello: Hello spring-boot-assembly +#mybatis +mybatis-plus: + #mapper-locations: classpath*:mappers/**/*.xml + #实体扫描,多个package用逗号或者分号分隔 + typeAliasesPackage: com.nebula.*.modules.*.entity + global-config: + # 数据库相关配置 + db-config: + #主键类型 AUTO:"数据库ID自增", INPUT:"用户输入ID",ID_WORKER:"全局唯一ID (数字类型唯一ID)", UUID:"全局唯一ID UUID"; + id-type: UUID + #字段策略 IGNORED:"忽略判断",NOT_NULL:"非 NULL 判断"),NOT_EMPTY:"非空判断" + field-strategy: not_empty + #驼峰下划线转换 + column-underline: true + # #数据库大写下划线转换 + # capital-mode: true + #逻辑删除配置 + logic-delete-value: 0 + logic-not-delete-value: 1 + # 原生配置 + configuration: + map-underscore-to-camel-case: true + #关闭缓存 + cache-enabled: false + default-enum-type-handler: org.apache.ibatis.type.EnumOrdinalTypeHandler + type-enums-package: com.nebula.common.enums \ No newline at end of file diff --git a/src/main/resources/mapper/demo/AppDemoMapper.xml b/src/main/resources/mapper/demo/AppDemoMapper.xml new file mode 100644 index 0000000..e4dd27b --- /dev/null +++ b/src/main/resources/mapper/demo/AppDemoMapper.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/hello/hello.xml b/src/main/resources/mapper/hello/hello.xml deleted file mode 100644 index 2eb4217..0000000 --- a/src/main/resources/mapper/hello/hello.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/main/resources/mapper/test.xml b/src/main/resources/mapper/test.xml deleted file mode 100644 index 08e9868..0000000 --- a/src/main/resources/mapper/test.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file -- Gitee From 97485ed9be28570ddc9b45d78bd588c8f7db14a8 Mon Sep 17 00:00:00 2001 From: EasternUnbeaten Date: Thu, 5 Mar 2020 16:09:50 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E8=A7=A3=E5=86=B3mybatis=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 8 ++------ src/main/assembly/assembly.xml | 4 ---- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index 5a92923..0616af5 100644 --- a/pom.xml +++ b/pom.xml @@ -100,9 +100,6 @@ src/main/resources true - - mapper/**/*.xml - application.yml application-${profileActive}.yml @@ -130,13 +127,12 @@ ../lib true - - resources/ - io/geekidea/springboot/** + + mapper/** diff --git a/src/main/assembly/assembly.xml b/src/main/assembly/assembly.xml index 9be7de1..2c390e6 100644 --- a/src/main/assembly/assembly.xml +++ b/src/main/assembly/assembly.xml @@ -34,13 +34,9 @@ ${basedir}/target/classes config 0644 - - mapper/**/*.xml - application.yml application-${profileActive}.yml - static/** templates/** *.xml -- Gitee From 3a6a63370b28fbb293c98231f59cf0c8031a3e6b Mon Sep 17 00:00:00 2001 From: Eastern unbeaten Date: Thu, 5 Mar 2020 22:32:33 -0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=8F=90=E4=BA=A4mybatis=E6=A1=86=E6=9E=B6?= =?UTF-8?q?=E4=BD=BF=E7=94=A8,mybatis-plus=E6=A1=86=E6=9E=B6=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E7=9A=84=E6=97=B6=E5=80=99=E6=A1=88=E4=BE=8B=E8=AF=B4?= =?UTF-8?q?=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index f724453..0cf80a2 100644 --- a/README.md +++ b/README.md @@ -160,6 +160,12 @@ io/geekidea/springboot/** + + mapper/** -- Gitee From 966ea1cb5f6152f02db7fd03a5bb6fc233f51f9d Mon Sep 17 00:00:00 2001 From: Eastern unbeaten Date: Thu, 5 Mar 2020 23:27:44 -0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93sql=E7=94=A8=E4=BE=8B=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- sql/APP_DEMO.sql | 24 ++++ .../springboot/assembly/Application.java | 2 +- src/main/resources/application-prod.yml | 16 --- src/main/resources/application.yml | 107 +++--------------- .../resources/mapper/demo/AppDemoMapper.xml | 2 +- 6 files changed, 40 insertions(+), 113 deletions(-) create mode 100644 sql/APP_DEMO.sql diff --git a/pom.xml b/pom.xml index 0616af5..274cb59 100644 --- a/pom.xml +++ b/pom.xml @@ -103,7 +103,7 @@ application.yml application-${profileActive}.yml - + mapper/**/*.xml static/** templates/** *.xml diff --git a/sql/APP_DEMO.sql b/sql/APP_DEMO.sql new file mode 100644 index 0000000..fb50d6c --- /dev/null +++ b/sql/APP_DEMO.sql @@ -0,0 +1,24 @@ + + +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for APP_DEMO +-- ---------------------------- +DROP TABLE IF EXISTS `APP_DEMO`; +CREATE TABLE `APP_DEMO` ( + `ID` varchar(100) COLLATE utf8_bin DEFAULT NULL, + `NAME` varchar(255) COLLATE utf8_bin DEFAULT NULL, + `CREATE_TIME` datetime DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + +-- ---------------------------- +-- Records of APP_DEMO +-- ---------------------------- +BEGIN; +INSERT INTO `APP_DEMO` VALUES ('ADSSADASDASDA', '张三', '2019-06-22 22:00:57'); +INSERT INTO `APP_DEMO` VALUES ('asdasdad', '阿斯达大', '2019-06-22 22:01:08'); +COMMIT; + +SET FOREIGN_KEY_CHECKS = 1; diff --git a/src/main/java/io/geekidea/springboot/assembly/Application.java b/src/main/java/io/geekidea/springboot/assembly/Application.java index 0fd3595..6c72413 100644 --- a/src/main/java/io/geekidea/springboot/assembly/Application.java +++ b/src/main/java/io/geekidea/springboot/assembly/Application.java @@ -12,7 +12,7 @@ import org.springframework.core.env.ConfigurableEnvironment; * @since 2018/11/20 */ @SpringBootApplication -@MapperScan("io.geekidea.springboot.assembly.mapper") +@MapperScan("io.geekidea.springboot.*.mapper") public class Application { public static void main(String[] args) { diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index 1bc844e..e69de29 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -1,16 +0,0 @@ -#druid sql 监控异常抛出配置 生产的时候异常就要抛出,测试环境,只要打印出来就行 -# 刚开始引入WallFilter的时候,把logViolation设置为true,而throwException设置为false。就可以观察是否存在违规的情况,同时不影响业务运行。 -#对被认为是攻击的SQL进行LOG.error输出 -druid-log-violation: false -#对被认为是攻击的SQL抛出SQLException -druid-throw-exception: true -datasource: - mysql: - validation-query: select 1 - driver: com.mysql.cj.jdbc.Driver - database: test - ip: 127.0.0.1 - port: 3306 - username: root - password: 123456 - url: jdbc:mysql://${datasource.mysql.ip}:${datasource.mysql.port}/${datasource.mysql.database}?useSSL=false&serverTimezone=UTC&characterEncoding=utf8 \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 0825776..9700cc7 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,13 +1,14 @@ -#配置sql监控的,你是什么数据库就写什么 mysql,mysql,sqlserver -druid-sql-type: mysql -#druid监控打开, stat-view stat,wall 全部引用到了,火力全开 -druid-enabled: true -#druid sql 监控异常抛出配置 生产的时候异常就要抛出,测试环境,只要打印出来就行 -# 刚开始引入WallFilter的时候,把logViolation设置为true,而throwException设置为false。就可以观察是否存在违规的情况,同时不影响业务运行。 -#对被认为是攻击的SQL进行LOG.error输出 -druid-log-violation: true -#对被认为是攻击的SQL抛出SQLException -druid-throw-exception: false +datasource: + mysql: + validation-query: select 1 + driver: com.mysql.cj.jdbc.Driver + #数据库名称 + database: nebula-web + ip: test + port: 3306 + username: root + password: 123456 + url: jdbc:mysql://${datasource.mysql.ip}:${datasource.mysql.port}/${datasource.mysql.database}?useSSL=false&serverTimezone=UTC&characterEncoding=utf8 server: servlet: context-path: /example @@ -21,98 +22,16 @@ spring: active: @profileActive@ datasource: druid: - stat-view-servlet: - loginUsername: ${datasource.druid.login-username} - loginPassword: ${datasource.druid.login-password} - enabled: ${druid-enabled} - #白名单IP白名单 (没有配置或者为空,则允许所有访问) - # allow: - #IP黑名单 (存在共同时,deny优先于allow) - # deny: - # url-pattern: /druid/* min-idle: 5 max-active: 10 initial-size: 1 - validation-query-timeout: 1 - #申请连接时执行validationQuery检测连接是否有效 - test-on-borrow: false - #归还连接时执行validationQuery检测连接是否有效 - test-on-return: false - #申请连接的时候检测,如果空闲时间大于timeBetweenEvictionRunsMillis,执行validationQuery检测连接是否有效。 - test-while-idle: true - # 获取连接时最大等待时间,单位毫秒。配置了maxWait之后,缺省启用公平锁,并发效率会有所下降,如果需要可以通过配置useUnfairLock属性为true使用非公平锁。 - max-wait: 30000 - # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 - time-between-eviction-runs-millis: 2000 - #连接保持空闲而不被驱逐的最小时间,单位是毫秒 - min-evictable-idle-time-millis: 600000 - max-evictable-idle-time-millis: 900000 - filter: - # https://github.com/alibaba/druid/wiki/%E9%85%8D%E7%BD%AE-wallfilter - stat: - db-type: ${druid-sql-type} - log-slow-sql: true - #2秒算慢sql - slow-sql-millis: 2000 - merge-sql: true - enabled: ${druid-enabled} - wall: - db-type: ${druid-sql-type} - config: - # 是否允许非以上基本语句的其他语句,缺省关闭,通过这个选项就能够屏蔽DDL。 - none-base-statement-allow: true - # 检查DELETE语句是否无where条件,这是有风险的,但不是SQL注入类型的风险 - delete-where-none-check: true - # 检查UPDATE语句是否无where条件,这是有风险的,但不是SQL注入类型的风险 - update-where-none-check: true - #是否允许 truncate语句 - truncate-allow: false - #是否允许drop表 - drop-table-allow: false - # 刚开始引入WallFilter的时候,把logViolation设置为true,而throwException设置为false。就可以观察是否存在违规的情况,同时不影响业务运行。 - #对被认为是攻击的SQL进行LOG.error输出 - log-violation: ${druid-log-violation} - #对被认为是攻击的SQL抛出SQLException - throw-exception: ${druid-throw-exception} - #是否开启过滤器 - enabled: ${druid-enabled} - filters: stat,wall - # 用来检测连接是否有效的sql,要求是一个查询语句。如果validationQuery为null,testOnBorrow、testOnReturn、testWhileIdle都不会其作用。 validation-query: ${datasource.mysql.validation-query} driver-class-name: ${datasource.mysql.driver} username: ${datasource.mysql.username} password: ${datasource.mysql.password} url: ${datasource.mysql.url} - # - keep-alive: true - phy-max-use-count: 500 - #异步关闭链接启用 - async-init: true - async-close-connection-enable: true + hello: Hello spring-boot-assembly #mybatis mybatis-plus: - #mapper-locations: classpath*:mappers/**/*.xml - #实体扫描,多个package用逗号或者分号分隔 - typeAliasesPackage: com.nebula.*.modules.*.entity - global-config: - # 数据库相关配置 - db-config: - #主键类型 AUTO:"数据库ID自增", INPUT:"用户输入ID",ID_WORKER:"全局唯一ID (数字类型唯一ID)", UUID:"全局唯一ID UUID"; - id-type: UUID - #字段策略 IGNORED:"忽略判断",NOT_NULL:"非 NULL 判断"),NOT_EMPTY:"非空判断" - field-strategy: not_empty - #驼峰下划线转换 - column-underline: true - # #数据库大写下划线转换 - # capital-mode: true - #逻辑删除配置 - logic-delete-value: 0 - logic-not-delete-value: 1 - # 原生配置 - configuration: - map-underscore-to-camel-case: true - #关闭缓存 - cache-enabled: false - default-enum-type-handler: org.apache.ibatis.type.EnumOrdinalTypeHandler - type-enums-package: com.nebula.common.enums \ No newline at end of file + mapper-locations: classpath*:mapper/**/*.xml diff --git a/src/main/resources/mapper/demo/AppDemoMapper.xml b/src/main/resources/mapper/demo/AppDemoMapper.xml index e4dd27b..df8b493 100644 --- a/src/main/resources/mapper/demo/AppDemoMapper.xml +++ b/src/main/resources/mapper/demo/AppDemoMapper.xml @@ -2,6 +2,6 @@ \ No newline at end of file -- Gitee