diff --git a/.gitignore b/.gitignore index d386c3123..efda2ecd4 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,4 @@ buildNumber.properties *.iml out gen +*DS_Store diff --git a/README.md b/README.md index 8b4f079eb..adaa4c79e 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ AOP实用技巧;比如打日志等 m3u parser https://github.com/BjoernPetersen/m3u-parser -知识汇总:::: +知识汇总: https://github.com/CyC2018/CS-Notes @@ -49,6 +49,10 @@ https://github.com/jobbole/awesome-java-cn https://mp.weixin.qq.com/s/kro_gyUQrdKSy1x3ETwb5A +限流组件 + +重试组件 + ## Others ## diff --git a/bage-spring-boot-starter-ping-test/pom.xml b/bage-spring-boot-starter-ping-test/pom.xml index 3304759e8..cbcef443e 100644 --- a/bage-spring-boot-starter-ping-test/pom.xml +++ b/bage-spring-boot-starter-ping-test/pom.xml @@ -15,7 +15,9 @@ http://www.example.com - UTF-8 + 1.8 + 1.8 + 2.0.1.RELEASE diff --git a/bage-spring-boot-starter-ping/README.md b/bage-spring-boot-starter-ping/README.md index 0f06dc689..e92d4f7ac 100644 --- a/bage-spring-boot-starter-ping/README.md +++ b/bage-spring-boot-starter-ping/README.md @@ -7,6 +7,8 @@ ``` UTF-8 + 1.8 + 1.8 2.0.1.RELEASE diff --git a/bage-spring-boot-starter-ping/pom.xml b/bage-spring-boot-starter-ping/pom.xml index 231aa7e42..45e6d816e 100644 --- a/bage-spring-boot-starter-ping/pom.xml +++ b/bage-spring-boot-starter-ping/pom.xml @@ -15,7 +15,9 @@ http://www.example.com - UTF-8 + 1.8 + 1.8 + 2.0.1.RELEASE diff --git a/pom.xml b/pom.xml index f4978018f..0942fd85d 100644 --- a/pom.xml +++ b/pom.xml @@ -16,6 +16,8 @@ UTF-8 + 1.8 + 1.8 study-spring-boot @@ -51,6 +53,7 @@ study-gateway study-sql study-quartz + study-guava study-shiro-web-tutorial study-rabbitmq study-tomcat @@ -135,7 +138,9 @@ study-summary study-id-generator study-stream-m3u8 + study-hystrix study-resilience4j study-ews-java-api @@ -144,7 +149,14 @@ study-sftp study-jmockit study-mockito + + study-file-online-preview + study-jol + study-servlet + study-lombok + study-spring-boot-elk \ No newline at end of file diff --git a/study-activemq/pom.xml b/study-activemq/pom.xml index b9c5f4a01..56365c9bc 100644 --- a/study-activemq/pom.xml +++ b/study-activemq/pom.xml @@ -11,7 +11,9 @@ study-activemq http://maven.apache.org - UTF-8 + + 1.8 + 1.8 diff --git a/study-algorithm/pom.xml b/study-algorithm/pom.xml index 727d0b784..5e77e61e9 100644 --- a/study-algorithm/pom.xml +++ b/study-algorithm/pom.xml @@ -11,7 +11,9 @@ study-algorithm http://maven.apache.org - UTF-8 + + 1.8 + 1.8 diff --git a/study-algorithm/src/main/java/com/bage/study/algorithm/leetcode/MinDeepTree.java b/study-algorithm/src/main/java/com/bage/study/algorithm/leetcode/MinDeepTree.java new file mode 100644 index 000000000..040f92cb5 --- /dev/null +++ b/study-algorithm/src/main/java/com/bage/study/algorithm/leetcode/MinDeepTree.java @@ -0,0 +1,24 @@ +package com.bage.study.algorithm.leetcode; + +import java.util.Objects; + + +/** + * https://leetcode-cn.com/problems/minimum-depth-of-binary-tree/ + * // todo ddd + */ +public class MinDeepTree { + public ListNode reverseList(ListNode head) { + if(Objects.isNull(head) || Objects.isNull(head.next)){ + return head; + } + ListNode listNode = reverseList(head.next); + head.next.next = head; + head.next = null; + return listNode; + } +} + +class TreeNode { + TreeNode next; + } diff --git a/study-algorithm/src/main/java/com/bage/study/algorithm/leetcode/RevertNodes.java b/study-algorithm/src/main/java/com/bage/study/algorithm/leetcode/RevertNodes.java new file mode 100644 index 000000000..8b11f3a5e --- /dev/null +++ b/study-algorithm/src/main/java/com/bage/study/algorithm/leetcode/RevertNodes.java @@ -0,0 +1,39 @@ +package com.bage.study.algorithm.leetcode; + +import java.util.Objects; + +/** + * https://leetcode-cn.com/problems/UHnkqh/ + */ +public class RevertNodes { +} + +/** + * Definition for singly-linked list. + * public class ListNode { + * int val; + * ListNode next; + * ListNode() {} + * ListNode(int val) { this.val = val; } + * ListNode(int val, ListNode next) { this.val = val; this.next = next; } + * } + */ +class Solution { + public ListNode reverseList(ListNode head) { + if(Objects.isNull(head) || Objects.isNull(head.next)){ + return head; + } + ListNode listNode = reverseList(head.next); + head.next.next = head; + head.next = null; + return listNode; + } +} + + class ListNode { + int val; + ListNode next; + ListNode() {} + ListNode(int val) { this.val = val; } + ListNode(int val, ListNode next) { this.val = val; this.next = next; } + } diff --git a/study-algorithm/src/main/java/com/bage/study/algorithm/leetcode/SortedArraySum.java b/study-algorithm/src/main/java/com/bage/study/algorithm/leetcode/SortedArraySum.java new file mode 100644 index 000000000..7ea6c3c56 --- /dev/null +++ b/study-algorithm/src/main/java/com/bage/study/algorithm/leetcode/SortedArraySum.java @@ -0,0 +1,19 @@ +package com.bage.study.algorithm.leetcode; + +import java.util.Objects; + +/** + * https://leetcode-cn.com/problems/kLl5u1/ + * SortedArraySum + */ +public class SortedArraySum { + public ListNode reverseList(ListNode head) { + if(Objects.isNull(head) || Objects.isNull(head.next)){ + return head; + } + ListNode listNode = reverseList(head.next); + head.next.next = head; + head.next = null; + return listNode; + } +} diff --git a/study-arthas/pom.xml b/study-arthas/pom.xml index 4be57d3d8..9dd285a0d 100644 --- a/study-arthas/pom.xml +++ b/study-arthas/pom.xml @@ -15,9 +15,9 @@ http://www.example.com - UTF-8 - 1.7 - 1.7 + + 1.8 + 1.8 diff --git a/study-axon/pom.xml b/study-axon/pom.xml index 9e9fb12ab..d515be186 100644 --- a/study-axon/pom.xml +++ b/study-axon/pom.xml @@ -28,8 +28,10 @@ - UTF-8 + 2.0.1.RELEASE + 1.8 + 1.8 diff --git a/study-baidu-asr/pom.xml b/study-baidu-asr/pom.xml index 91eec1b40..8148c0532 100644 --- a/study-baidu-asr/pom.xml +++ b/study-baidu-asr/pom.xml @@ -16,9 +16,9 @@ http://www.example.com - UTF-8 - 1.7 - 1.7 + + 1.8 + 1.8 diff --git a/study-cache-memory-spring/pom.xml b/study-cache-memory-spring/pom.xml index 4c4ff630f..d2a5d1a1f 100644 --- a/study-cache-memory-spring/pom.xml +++ b/study-cache-memory-spring/pom.xml @@ -17,7 +17,7 @@ 1.8 1.8 - UTF-8 + 4.1.9.RELEASE UTF-8 3.0-alpha-1 diff --git a/study-cache-memory-springboot/pom.xml b/study-cache-memory-springboot/pom.xml index 8797be462..0bcf07fae 100644 --- a/study-cache-memory-springboot/pom.xml +++ b/study-cache-memory-springboot/pom.xml @@ -13,6 +13,8 @@ http://maven.apache.org UTF-8 + 1.8 + 1.8 2.0.1.RELEASE diff --git a/study-cas-client/pom.xml b/study-cas-client/pom.xml index 8cea223aa..767d2604b 100644 --- a/study-cas-client/pom.xml +++ b/study-cas-client/pom.xml @@ -14,7 +14,8 @@ 3.5.0 - + 1.8 + 1.8 UTF-8 4.3.9.RELEASE UTF-8 diff --git a/study-cas-server/pom.xml b/study-cas-server/pom.xml index 78baad5a2..010a91936 100644 --- a/study-cas-server/pom.xml +++ b/study-cas-server/pom.xml @@ -16,4 +16,12 @@ study-cas-server + + + UTF-8 + 1.8 + 1.8 + + + diff --git a/study-cglib/pom.xml b/study-cglib/pom.xml index cd0a8c220..245d62f24 100644 --- a/study-cglib/pom.xml +++ b/study-cglib/pom.xml @@ -12,6 +12,8 @@ http://maven.apache.org UTF-8 + 1.8 + 1.8 diff --git a/study-code-format/pom.xml b/study-code-format/pom.xml index 4a418a669..a459d0a1a 100644 --- a/study-code-format/pom.xml +++ b/study-code-format/pom.xml @@ -12,6 +12,8 @@ http://maven.apache.org UTF-8 + 1.8 + 1.8 diff --git a/study-cryption/pom.xml b/study-cryption/pom.xml index 1e5a3d6b4..68017bc2c 100644 --- a/study-cryption/pom.xml +++ b/study-cryption/pom.xml @@ -12,6 +12,8 @@ http://maven.apache.org UTF-8 + 1.8 + 1.8 diff --git a/study-cxf/pom.xml b/study-cxf/pom.xml index 6f6684dcf..179a882bf 100644 --- a/study-cxf/pom.xml +++ b/study-cxf/pom.xml @@ -19,6 +19,8 @@ 3.1.9 1.9.13 4.1.9.RELEASE + 1.8 + 1.8 diff --git a/study-dbschema-to-json/pom.xml b/study-dbschema-to-json/pom.xml index b4c56e0d5..2b8432bf4 100644 --- a/study-dbschema-to-json/pom.xml +++ b/study-dbschema-to-json/pom.xml @@ -20,6 +20,8 @@ UTF-8 2.0.1.RELEASE springio + 1.8 + 1.8 diff --git a/study-docker/README.md b/study-docker/README.md index 8eba4506b..ac0d1e7e8 100644 --- a/study-docker/README.md +++ b/study-docker/README.md @@ -41,6 +41,30 @@ Most users set up Docker’s repositories and install from them, for ease of ins 配置开机启动 > systemctl enable docker + + +docker hub 设置国内镜像地址 + +https://www.csdn.net/tags/NtzaMgzsNDA4Ni1ibG9n.html + +在任务栏点击 Docker Desktop 应用图标 -> Perferences,在左侧导航菜单选择 Docker Engine,在右侧像下边一样编辑 json 文件。修改完成之后,点击 Apply & Restart 按钮,Docker 就会重启并应用配置的镜像地址了。 + +```json +{ + "registry-mirrors": [ + "https://9cpn8tt6.mirror.aliyuncs.com", + "https://hub-mirror.c.163.com", + "https://registry.docker-cn.com" + ] +} +``` + +验证 + +``` +docker info +``` + ## 常用命令 ## ### Docker ### @@ -135,9 +159,37 @@ Docker Pull Command docker pull mysql +Mac M1 报错 + +``` +docker pull mysql + +Using default tag: latest + +latest: Pulling from library/mysql + +no matching manifest for linux/arm64/v8 in the manifest list entries + +``` + +解决方案 + +``` +docker pull mysql/mysql-server +``` + + + Start a mysql server instance docker run --name bage-mysql -v /home/bage/data/mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=bage -p 3306:3306 -d bage-mysql + + Mac: + docker run --name bage-mysql -v /Users/bage/bage/docker-data/mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=bage -p 3306:3306 -d mysql/mysql-server + + +​ +​ 其中 --name 起名 bage-mysql @@ -369,21 +421,27 @@ Docker Pull Command Docker Pull Command docker pull elasticsearch:7.5.1 + + Mac M1 + docker pull elasticsearch:7.16.2 + + 启动 docker run --network myapp --name elasticsearch -p 9092:9200 -p 8093:9300 -e "discovery.type=single-node" elasticsearch:7.5.1 + + Mac + docker run --network myapp --name elasticsearch -p 9092:9200 -p 8093:9300 -e "discovery.type=single-node" elasticsearch:7.11.1 - - - - - 访问 http://{ip}:9092/_cat/health + + http://127.0.0.1:9092/_cat/health + http://127.0.0.1:8093/_cat/health ### 安装部署 zipkin ### @@ -682,6 +740,9 @@ start a instance + + + ### 安装配置 logstash ### 版本匹配 https://www.elastic.co/cn/support/matrix#matrix_compatibility 参考链接:[https://www.elastic.co/guide/en/logstash/current/docker.html](https://www.elastic.co/guide/en/logstash/current/docker.html)、[https://hub.docker.com/_/logstash?tab=description](https://hub.docker.com/_/logstash?tab=description)、[https://www.elastic.co/guide/en/logstash/current/docker-config.html](https://www.elastic.co/guide/en/logstash/current/docker-config.html) @@ -689,6 +750,9 @@ start a instance Docker Pull Command docker pull logstash:7.5.1 + + Mac M1 + docker pull logstash:7.16.2 start a instance[not enough space] @@ -709,28 +773,39 @@ setting max_map_count sudo sysctl -w vm.max_map_count=262144 vi /home/bage/data/logstash/file-beats.conf - - # 数据输入配置:port -> 端口号;codec -> 输入格式。这里以logback为例。 - input { - tcp { - port => 5044 - codec=>json_lines - } - } - - # 数据输出配置:hosts -> 主机集合;index -> 你将要创建的索引名称。这里es为例。 - output { - elasticsearch { - hosts => ["127.0.0.1:9200"] - index => "%{[appName]}-%{+YYYY.MM.dd}" - } - } + +[Mac: /Users/bage/bage/docker-data/elk/logstash/beats-input.conf] + +``` +# 数据输入配置:port -> 端口号;codec -> 输入格式。这里以logback为例。 +input { + tcp { + port => 5044 + codec=>json_lines + } +} + +# 数据输出配置:hosts -> 主机集合;index -> 你将要创建的索引名称。这里es为例。 +output { + elasticsearch { + hosts => ["127.0.0.1:9200"] + index => "%{[appName]}-%{+YYYY.MM.dd}" + } +} +``` + + start a instance docker run -v /home/bage/data/logstash/file-beats.conf:/etc/logstash/conf.d/02-beats-input.conf -p 8056:5601 -p 8092:9200 -p 8044:5044 -it --name elk sebp/elk:700 - + + Mac: + docker run -v /Users/bage/bage/docker-data/elk/logstash/beats-input.conf:/etc/logstash/conf.d/02-beats-input.conf -p 8056:5601 -p 8092:9200 -p 8044:5044 -it --name elk sebp/elk:700 + + Mac[多目录挂载问题]: + docker run -e MAX_MAP_COUNT="262144" -v /Users/bage/bage/docker-data/elk/es:/var/lib/elasticsearch -v /Users/bage/bage/docker-data/elk/logstash/beats-input.conf:/etc/logstash/conf.d/02-beats-input.conf -p 8056:5601 -p 8092:9200 -p 8044:5044 -it --name elk sebp/elk:700 访问 @@ -752,6 +827,10 @@ kibana Docker Pull Command docker pull kibana:7.5.1 + + Mac + docker pull kibana:7.16.2 + start a instance diff --git a/study-docker/pom.xml b/study-docker/pom.xml index 5da7b633f..80de25688 100644 --- a/study-docker/pom.xml +++ b/study-docker/pom.xml @@ -12,6 +12,8 @@ http://maven.apache.org UTF-8 + 1.8 + 1.8 diff --git a/study-domain-generator/pom.xml b/study-domain-generator/pom.xml index c8ddc6f4b..be75927c2 100644 --- a/study-domain-generator/pom.xml +++ b/study-domain-generator/pom.xml @@ -17,8 +17,8 @@ UTF-8 - 1.7 - 1.7 + 1.8 + 1.8 diff --git a/study-downtime/pom.xml b/study-downtime/pom.xml index 767c63199..efed404c9 100644 --- a/study-downtime/pom.xml +++ b/study-downtime/pom.xml @@ -17,8 +17,8 @@ UTF-8 - 1.7 - 1.7 + 1.8 + 1.8 diff --git a/study-draw-io/Untitled Diagram.drawio b/study-draw-io/Untitled Diagram.drawio new file mode 100644 index 000000000..4aac42e27 --- /dev/null +++ b/study-draw-io/Untitled Diagram.drawio @@ -0,0 +1,175 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/study-draw-io/readme.MD b/study-draw-io/readme.MD new file mode 100644 index 000000000..30d82be33 --- /dev/null +++ b/study-draw-io/readme.MD @@ -0,0 +1,3 @@ + +Draw IO ļ + diff --git a/study-draw-io/tis-call-trace.drawio b/study-draw-io/tis-call-trace.drawio new file mode 100644 index 000000000..f2f89c3bb --- /dev/null +++ b/study-draw-io/tis-call-trace.drawio @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/study-dubbo/pom.xml b/study-dubbo/pom.xml index dc3c034fd..1a9fae841 100644 --- a/study-dubbo/pom.xml +++ b/study-dubbo/pom.xml @@ -12,6 +12,8 @@ http://maven.apache.org UTF-8 + 1.8 + 1.8 @@ -30,7 +32,7 @@ org.apache.zookeeper zookeeper - 3.3.3 + 3.4.13 diff --git a/study-easyexcel/pom.xml b/study-easyexcel/pom.xml index 8ce90bfcb..6ac3584f3 100644 --- a/study-easyexcel/pom.xml +++ b/study-easyexcel/pom.xml @@ -17,8 +17,8 @@ UTF-8 - 1.7 - 1.7 + 1.8 + 1.8 diff --git a/study-ehcache/pom.xml b/study-ehcache/pom.xml index 07fdaac42..c3496a5e9 100644 --- a/study-ehcache/pom.xml +++ b/study-ehcache/pom.xml @@ -12,6 +12,14 @@ war study-ehcache Maven Webapp http://maven.apache.org + + + + UTF-8 + 1.8 + 1.8 + + junit diff --git a/study-es/pom.xml b/study-es/pom.xml index 27263ec1f..7598cf0ea 100644 --- a/study-es/pom.xml +++ b/study-es/pom.xml @@ -17,8 +17,8 @@ UTF-8 - 1.7 - 1.7 + 1.8 + 1.8 diff --git a/study-ews-java-api/pom.xml b/study-ews-java-api/pom.xml index 581a4e24c..d95793383 100644 --- a/study-ews-java-api/pom.xml +++ b/study-ews-java-api/pom.xml @@ -13,8 +13,8 @@ UTF-8 - 1.7 - 1.7 + 1.8 + 1.8 diff --git a/study-file-online-preview/README.md b/study-file-online-preview/README.md new file mode 100644 index 000000000..b4d1a82e8 --- /dev/null +++ b/study-file-online-preview/README.md @@ -0,0 +1,2 @@ +https://gitee.com/kekingcn/file-online-preview/blob/master/README.md + diff --git a/study-file-online-preview/pom.xml b/study-file-online-preview/pom.xml new file mode 100644 index 000000000..1243963f1 --- /dev/null +++ b/study-file-online-preview/pom.xml @@ -0,0 +1,23 @@ + + + + study + com.bage + 0.0.1-SNAPSHOT + + 4.0.0 + + study-file-online-preview + + + 8 + 8 + + + + + + + \ No newline at end of file diff --git a/study-flutter/README.md b/study-flutter/README.md index 4a3739342..171ff987b 100644 --- a/study-flutter/README.md +++ b/study-flutter/README.md @@ -6,7 +6,8 @@ D:\softwares\SDK\emulator\emulator -avd Pixel2XLAPI29 -dns-server 10.0.3.2 flutter build apk --no-sound-null-safety ``` - +盛情域名??? +服务器 ?? ## Flutter 入门 @@ -17,18 +18,16 @@ https://developer.android.google.cn/studio/run/managing-avds#createavd https://fluttergems.dev/ -### TODO - -发布线上 +https://github.com/jahnli/awesome-flutter-plugins -用户评价 +### TODO -版本信息 +服务端代码改造 网络提示,请先连接网络 同意提示,多语言问题 -下载进度条(参考https://github.com/rhymelph/r_upgrade/blob/v0.3.2/README_CN.md) +下载进度条(参考 https://github.com/rhymelph/r_upgrade/blob/v0.3.2/README_CN.md) 分享 @@ -38,6 +37,29 @@ https://fluttergems.dev/ 大厂内推APP +https://github.com/lohanidamodar/flutter_ui_challenges + + + +https://github.com/FlutterOpen/flutter-ui-nice + + + + + +小组活动:每周体验一款app,产品包括最近热门,评价高,国外好的产品。建议从产品、市场两方面发表看法,也可以自由交流~ +产品方面: +1.主要功能 +2.解决用户什么需求 +3.独特卖点 +4.关键指标 + +市场方面: +1.用户群 +2.推广渠道 +3.收入分析 +4.成本分析 + app idea reference: @@ -71,6 +93,8 @@ https://github.com/mitesh77/Best-Flutter-UI-Templates https://github.com/iampawan/Flutter-UI-Kit +https://github.com/olayemii/flutter-ui-kits + https://github.com/flutter/gallery/tree/master/lib diff --git a/study-flutter/lib/component/event/BaseEvent.dart b/study-flutter/lib/component/event/BaseEvent.dart new file mode 100644 index 000000000..4e53e9c0b --- /dev/null +++ b/study-flutter/lib/component/event/BaseEvent.dart @@ -0,0 +1,3 @@ + + +class BaseEvent {} diff --git a/study-flutter/lib/component/event/EventBus.dart b/study-flutter/lib/component/event/EventBus.dart index bd06cc88e..4db7757de 100644 --- a/study-flutter/lib/component/event/EventBus.dart +++ b/study-flutter/lib/component/event/EventBus.dart @@ -1,6 +1,6 @@ import 'package:event_bus/event_bus.dart' as marcojakob; -import 'EventListener.dart'; +typedef EventCallback = void Function(dynamic event); class EventBus { static marcojakob.EventBus _eventBus = marcojakob.EventBus(); @@ -9,10 +9,10 @@ class EventBus { _eventBus.fire(event); } - static void initConsumers() { - _eventBus.on().listen((event) { + static void consume(EventCallback callback) { + _eventBus.on().listen((event) { // All events are of type UserLoggedInEvent (or subtypes of it). - event.consume(event.data); + callback(event); }); } } diff --git a/study-flutter/lib/component/event/EventListener.dart b/study-flutter/lib/component/event/EventListener.dart deleted file mode 100644 index 20c54a8c5..000000000 --- a/study-flutter/lib/component/event/EventListener.dart +++ /dev/null @@ -1,7 +0,0 @@ -abstract class EventListener { - - dynamic data; - - void consume(dynamic data); - -} diff --git a/study-flutter/lib/startup/Application.dart b/study-flutter/lib/startup/Application.dart index a6d7dc46b..21d52db2b 100644 --- a/study-flutter/lib/startup/Application.dart +++ b/study-flutter/lib/startup/Application.dart @@ -1,7 +1,6 @@ import 'package:app_lu_lu/component/cache/HttpRequestCaches.dart'; import 'package:app_lu_lu/component/cache/TvCaches.dart'; import 'package:app_lu_lu/component/cache/UserCaches.dart'; -import 'package:app_lu_lu/component/event/EventBus.dart'; import 'package:app_lu_lu/component/http/HttpRequests.dart'; import 'package:app_lu_lu/utils/AppUtils.dart'; import 'package:flutter/cupertino.dart'; @@ -16,6 +15,5 @@ class Application { AppUtils.getDeviceId() .then((deviceId) => {UserCaches.setUserId(deviceId.hashCode)}); HttpRequests.init(); - EventBus.initConsumers(); } } diff --git a/study-flutter/lib/view/settings/FeedbackTabView.dart b/study-flutter/lib/view/settings/FeedbackTabView.dart index c91aab981..ca9b12d31 100644 --- a/study-flutter/lib/view/settings/FeedbackTabView.dart +++ b/study-flutter/lib/view/settings/FeedbackTabView.dart @@ -3,6 +3,7 @@ import 'dart:convert'; import 'package:app_lu_lu/component/cache/UserCaches.dart'; import 'package:app_lu_lu/component/dialog/Dialogs.dart'; +import 'package:app_lu_lu/component/event/EventBus.dart'; import 'package:app_lu_lu/component/http/HttpRequests.dart'; import 'package:app_lu_lu/component/log/Logs.dart'; import 'package:app_lu_lu/constant/HttpConstant.dart'; @@ -11,6 +12,7 @@ import 'package:app_lu_lu/locale/Translations.dart'; import 'package:app_lu_lu/model/AboutAuthorTab.dart'; import 'package:app_lu_lu/model/AppFeedback.dart'; import 'package:app_lu_lu/model/FeedbackQueryResult.dart'; +import 'package:app_lu_lu/view/settings/FeedbackUpdateEvent.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -67,6 +69,10 @@ class _FeedbackTabState extends State<_FeedbackTabView> { void initState() { showLoading(); _onRefresh(); + EventBus.consume((event) { + Logs.info('event = ${event.toString()}'); + _onRefresh(); + }); } @override @@ -270,6 +276,9 @@ class _FeedbackTabState extends State<_FeedbackTabView> { } Future _onRefresh() async { + if (!mounted) { + return ; + } Map paramJson = new HashMap(); paramJson.putIfAbsent("targetPage", () => 1); paramJson.putIfAbsent("pageSize", () => 100); diff --git a/study-flutter/lib/view/settings/FeedbackUpdateEvent.dart b/study-flutter/lib/view/settings/FeedbackUpdateEvent.dart index 24ea24280..234b3c842 100644 --- a/study-flutter/lib/view/settings/FeedbackUpdateEvent.dart +++ b/study-flutter/lib/view/settings/FeedbackUpdateEvent.dart @@ -1,13 +1,5 @@ -import 'package:app_lu_lu/component/event/EventListener.dart'; -import 'package:app_lu_lu/component/log/Logs.dart'; +import 'package:app_lu_lu/component/event/BaseEvent.dart'; -class FeedbackUpdateEvent implements BaseEvent { - @override - var data; - - @override - void consume(data) { - Logs.info("FeedbackUpdateEvent --- "); - Logs.info(data.toString()); - } +class FeedbackUpdateEvent extends BaseEvent { + String data = "hello world"; } diff --git a/study-flutter/lib/view/settings/Feedbacks.dart b/study-flutter/lib/view/settings/Feedbacks.dart index c81e8ea23..0aa79d716 100644 --- a/study-flutter/lib/view/settings/Feedbacks.dart +++ b/study-flutter/lib/view/settings/Feedbacks.dart @@ -43,7 +43,7 @@ class _Feedbacks extends State with SingleTickerProviderStateMixin { Logs.info('_insertFeedback responseBody=' + (result?.responseBody ?? "")); setState(() { FeedbackUpdateEvent event = FeedbackUpdateEvent(); - event.data = 1234; + event.data = "hhh"; EventBus.publish(event); }); }).catchError((error) { diff --git a/study-gateway-test/pom.xml b/study-gateway-test/pom.xml index e1ac27ffb..75bb9c8b0 100644 --- a/study-gateway-test/pom.xml +++ b/study-gateway-test/pom.xml @@ -13,6 +13,8 @@ UTF-8 2.0.1.RELEASE + 1.8 + 1.8 diff --git a/study-gateway/pom.xml b/study-gateway/pom.xml index 4936e209d..3fce83b51 100644 --- a/study-gateway/pom.xml +++ b/study-gateway/pom.xml @@ -14,6 +14,8 @@ UTF-8 2.0.1.RELEASE + 1.8 + 1.8 diff --git a/study-guava/pom.xml b/study-guava/pom.xml index add009e3c..cb63a0c6b 100644 --- a/study-guava/pom.xml +++ b/study-guava/pom.xml @@ -14,6 +14,8 @@ UTF-8 2.0.1.RELEASE + 1.8 + 1.8 @@ -54,6 +56,11 @@ guava-testlib 26.0-jre + + com.github.rholder + guava-retrying + 2.0.0 + com.google.truth diff --git a/study-guava/src/main/java/com/bage/study/guava/RetryDemo.java b/study-guava/src/main/java/com/bage/study/guava/RetryDemo.java new file mode 100644 index 000000000..9dc8b4bfc --- /dev/null +++ b/study-guava/src/main/java/com/bage/study/guava/RetryDemo.java @@ -0,0 +1,53 @@ +package com.bage.study.guava; + +import com.github.rholder.retry.RetryException; +import com.github.rholder.retry.Retryer; +import com.github.rholder.retry.RetryerBuilder; +import com.github.rholder.retry.StopStrategies; +import com.google.common.base.Predicates; + +import java.io.IOException; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutionException; + +public class RetryDemo { + + private static int count = 0; + + public static void main(String[] args) { + + Callable callable = new Callable() { + public Boolean call() throws Exception { + System.out.println(count ++); + if(count <= 2){ + throw new IOException(); + } + return true; // do something useful here + } + }; + + Retryer retryer = RetryerBuilder.newBuilder() + .retryIfResult(Predicates.isNull()) + .retryIfExceptionOfType(IOException.class) + .retryIfRuntimeException() + .withStopStrategy(StopStrategies.stopAfterAttempt(5)) + .build(); + +// Retryer retryer = RetryerBuilder.newBuilder() +// .retryIfExceptionOfType(IOException.class) +// .retryIfRuntimeException() +// .withWaitStrategy(WaitStrategies.exponentialWait(100, 5, TimeUnit.MINUTES)) +// .withStopStrategy(StopStrategies.neverStop()) +// .build(); + + try { + retryer.call(callable); + } catch (RetryException e) { + e.printStackTrace(); + } catch (ExecutionException e) { + e.printStackTrace(); + } + + + } +} diff --git a/study-hanlp/pom.xml b/study-hanlp/pom.xml index aa2400b9d..22ac121ae 100644 --- a/study-hanlp/pom.xml +++ b/study-hanlp/pom.xml @@ -17,8 +17,8 @@ UTF-8 - 1.7 - 1.7 + 1.8 + 1.8 diff --git a/study-hashids-java/pom.xml b/study-hashids-java/pom.xml index 29ac2d90d..f76fd981b 100644 --- a/study-hashids-java/pom.xml +++ b/study-hashids-java/pom.xml @@ -16,8 +16,8 @@ UTF-8 - 1.7 - 1.7 + 1.8 + 1.8 diff --git a/study-html2pdf/pom.xml b/study-html2pdf/pom.xml index 8c16a0ecf..0d41e8366 100644 --- a/study-html2pdf/pom.xml +++ b/study-html2pdf/pom.xml @@ -17,8 +17,8 @@ UTF-8 - 1.7 - 1.7 + 1.8 + 1.8 diff --git a/study-hystrix/pom.xml b/study-hystrix/pom.xml index 7d6357157..f9aed99b7 100644 --- a/study-hystrix/pom.xml +++ b/study-hystrix/pom.xml @@ -13,8 +13,8 @@ UTF-8 - 1.7 - 1.7 + 1.8 + 1.8 diff --git a/study-id-generator/pom.xml b/study-id-generator/pom.xml index 5aed39b6e..96c8e6d36 100644 --- a/study-id-generator/pom.xml +++ b/study-id-generator/pom.xml @@ -17,8 +17,8 @@ UTF-8 - 1.7 - 1.7 + 1.8 + 1.8 diff --git a/study-itext/pom.xml b/study-itext/pom.xml index cfa8a1077..22d84d440 100644 --- a/study-itext/pom.xml +++ b/study-itext/pom.xml @@ -17,8 +17,8 @@ UTF-8 - 1.7 - 1.7 + 1.8 + 1.8 @@ -37,7 +37,7 @@ net.sf.cssbox pdf2dom - 1.6 + 1.8 @@ -65,49 +65,4 @@ - - - - - - maven-clean-plugin - 3.1.0 - - - - maven-resources-plugin - 3.0.2 - - - maven-compiler-plugin - 3.8.0 - - - maven-surefire-plugin - 2.22.1 - - - maven-jar-plugin - 3.0.2 - - - maven-install-plugin - 2.5.2 - - - maven-deploy-plugin - 2.8.2 - - - - maven-site-plugin - 3.7.1 - - - maven-project-info-reports-plugin - 3.0.0 - - - - diff --git a/study-java-agent-instrument/pom.xml b/study-java-agent-instrument/pom.xml index 13ee23c79..becd6db0e 100644 --- a/study-java-agent-instrument/pom.xml +++ b/study-java-agent-instrument/pom.xml @@ -13,7 +13,7 @@ http://maven.apache.org pom - 1.0-SNAPSHOT + 0.0.1-SNAPSHOT study-java-agent-demo-service study-java-agent-transform-service diff --git a/study-java-agent-instrument/study-java-agent-attach/pom.xml b/study-java-agent-instrument/study-java-agent-attach/pom.xml index fab61b7e3..07fad242f 100644 --- a/study-java-agent-instrument/study-java-agent-attach/pom.xml +++ b/study-java-agent-instrument/study-java-agent-attach/pom.xml @@ -3,18 +3,22 @@ 4.0.0 + + study-java-agent-instrument + com.bage + 0.0.1-SNAPSHOT + - org.example + com.bage study-java-agent-attach - 1.0-SNAPSHOT study-java-agent-attach http://www.example.com UTF-8 - 1.7 - 1.7 + 1.8 + 1.8 diff --git a/study-java-agent-instrument/study-java-agent-demo-service/pom.xml b/study-java-agent-instrument/study-java-agent-demo-service/pom.xml index bccf6410c..1dcde2831 100644 --- a/study-java-agent-instrument/study-java-agent-demo-service/pom.xml +++ b/study-java-agent-instrument/study-java-agent-demo-service/pom.xml @@ -3,9 +3,9 @@ - study-java-agent - org.example - 1.0-SNAPSHOT + study-java-agent-instrument + com.bage + 0.0.1-SNAPSHOT 4.0.0 @@ -16,8 +16,8 @@ UTF-8 - 1.7 - 1.7 + 1.8 + 1.8 diff --git a/study-java-agent-instrument/study-java-agent-hotload-service/pom.xml b/study-java-agent-instrument/study-java-agent-hotload-service/pom.xml index b64d089b4..934b50c43 100644 --- a/study-java-agent-instrument/study-java-agent-hotload-service/pom.xml +++ b/study-java-agent-instrument/study-java-agent-hotload-service/pom.xml @@ -3,18 +3,22 @@ 4.0.0 + + study-java-agent-instrument + com.bage + 0.0.1-SNAPSHOT + - org.example + com.bage study-java-agent-hotload-service - 1.0-SNAPSHOT study-java-agent-hotload-service http://www.example.com UTF-8 - 1.7 - 1.7 + 1.8 + 1.8 diff --git a/study-java-agent-instrument/study-java-agent-transform-service/pom.xml b/study-java-agent-instrument/study-java-agent-transform-service/pom.xml index c3e150187..95d66559e 100644 --- a/study-java-agent-instrument/study-java-agent-transform-service/pom.xml +++ b/study-java-agent-instrument/study-java-agent-transform-service/pom.xml @@ -3,9 +3,9 @@ - study-java-agent - org.example - 1.0-SNAPSHOT + study-java-agent-instrument + com.bage + 0.0.1-SNAPSHOT 4.0.0 @@ -16,8 +16,8 @@ UTF-8 - 1.7 - 1.7 + 1.8 + 1.8 diff --git a/study-java-shell/pom.xml b/study-java-shell/pom.xml index 60ef765cd..7c0b11346 100644 --- a/study-java-shell/pom.xml +++ b/study-java-shell/pom.xml @@ -17,8 +17,8 @@ UTF-8 - 1.7 - 1.7 + 1.8 + 1.8 diff --git a/study-java/.DS_Store b/study-java/.DS_Store new file mode 100644 index 000000000..ce9e716a9 Binary files /dev/null and b/study-java/.DS_Store differ diff --git a/study-java/README.md b/study-java/README.md index 1379db1e1..328caa433 100644 --- a/study-java/README.md +++ b/study-java/README.md @@ -16,6 +16,21 @@ - 对敏感字段加密 - 序列化存储规则 +### java 线程池 + +- 参数 +- 提交过程 +- 结束过程 +- 注意事项 + +参考: 池子技术:https://mp.weixin.qq.com/s?__biz=MzUxMzQ0Njc1NQ==&mid=2247494137&idx=1&sn=85962cae0f772c2b41298dd322c6ce5a&chksm=f957aff5ce2026e3201a7b26c08cce9788b340ae371e432b13ef8d035f491cbc55ff3a6b9b79&scene=126&sessionid=1631634578&key=4f90c08c96d622750d1f94cfc9c828d2b4f9b8a4d242217acb0c892b1f5b508c3361dc32b972957612ff0fb223133a8ce49e1f65df8f4ce0aea14a1ee9521ba15fb08ac413c4a7ec31cddc52f10866e62f5854ceb9c8f6d4fc71e97d72416567c92af6c1b4572fb0e40c90d6e037f8e77fc6424650165ad3aa2d40bbe19947fa&ascene=1&uin=MjU5MTQ1MDcxMQ%3D%3D&devicetype=Windows+10+x64&version=6302019c&lang=zh_CN&exportkey=A%2FarF0N%2Fbt0u8YbyerDiyRY%3D&pass_ticket=Uc9EXPQYEBD8FJh0ig5oIlm3BsTVmcxdxPOZc%2BFgOdCZbEfmuz9f7krxzG470APE&wx_header=0&fontgear=2 + +### 阻塞队列 + +- 阻塞队列常见实现 +- 常用方法 +- 阻塞队列实现 +- 手写一个阻塞队列 怎么实现Java的序列化 diff --git a/study-java/src/main/java/com/bage/study/java/debug/DebugTest.java b/study-java/src/main/java/com/bage/study/java/debug/DebugTest.java new file mode 100644 index 000000000..5db740bb5 --- /dev/null +++ b/study-java/src/main/java/com/bage/study/java/debug/DebugTest.java @@ -0,0 +1,19 @@ +package com.bage.study.java.debug; + +public class DebugTest { + + public static void main(String[] args) { + + int n = 10; + for (int i = 0; i < n; i++) { + System.out.println(i); + // debug + // 先 选好 断点 + // 在 右键 断点 + // 设置停留条件即可 + } + System.out.println("end "); + + } + +} diff --git a/study-java/src/main/java/com/bage/study/java/java8/DurationTest.java b/study-java/src/main/java/com/bage/study/java/java8/DurationTest.java new file mode 100644 index 000000000..3c84f9caf --- /dev/null +++ b/study-java/src/main/java/com/bage/study/java/java8/DurationTest.java @@ -0,0 +1,28 @@ +package com.bage.study.java.java8; + +import java.time.Duration; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.Period; + +/** + * Java 8的新特性 + * @author bage + * + */ +public class DurationTest { + + + public static void main(String[] args) { + LocalDateTime now = LocalDateTime.now(); + LocalDate now2 = LocalDate.now(); + + System.out.println(Duration.between(now, now.plusHours(2)).toString()); + System.out.println(Duration.between(now, now.plusDays(10)).toString()); + System.out.println(Duration.between(now, now.plusMinutes(2)).toString()); + + + System.out.println(Period.between(now2, now2.plusDays(10)).toString()); + + } +} diff --git a/study-java/src/main/java/com/bage/study/java/java8/PeriodTest.java b/study-java/src/main/java/com/bage/study/java/java8/PeriodTest.java new file mode 100644 index 000000000..75307b0f0 --- /dev/null +++ b/study-java/src/main/java/com/bage/study/java/java8/PeriodTest.java @@ -0,0 +1,19 @@ +package com.bage.study.java.java8; + +import java.time.LocalDate; +import java.time.Period; + +/** + * @author bage + * + */ +public class PeriodTest { + + + public static void main(String[] args) { + LocalDate now = LocalDate.now(); + + System.out.println(Period.between(now, now.plusDays(2)).toString()); + + } +} diff --git a/study-java/src/main/java/com/bage/study/java/multhread/MyThreadPoolExecutor.java b/study-java/src/main/java/com/bage/study/java/multhread/MyThreadPoolExecutor.java index e93f00cf3..91677a544 100644 --- a/study-java/src/main/java/com/bage/study/java/multhread/MyThreadPoolExecutor.java +++ b/study-java/src/main/java/com/bage/study/java/multhread/MyThreadPoolExecutor.java @@ -80,7 +80,8 @@ public void run() { // SynchronousQueue, // LinkedBlockingDeque, // ArrayBlockingQueue; - + +// threadPoolExecutor.shutdownNow(); } } diff --git a/study-java/src/main/java/com/bage/study/java/multhread/ThreadTest.java b/study-java/src/main/java/com/bage/study/java/multhread/ThreadTest.java new file mode 100644 index 000000000..6cb5b250c --- /dev/null +++ b/study-java/src/main/java/com/bage/study/java/multhread/ThreadTest.java @@ -0,0 +1,16 @@ +package com.bage.study.java.multhread; + +/** + * 多线程顺序执行实现 + * + * @author bage + */ +public class ThreadTest { + + public static void main(String[] args) throws Exception { + Thread thread1 = new ThreadSeq1(); + thread1.start(); + } + +} + diff --git a/study-java/src/main/java/com/bage/study/java/proxy/JdkProxyTest.java b/study-java/src/main/java/com/bage/study/java/proxy/JdkProxyTest.java new file mode 100644 index 000000000..4f437ca1e --- /dev/null +++ b/study-java/src/main/java/com/bage/study/java/proxy/JdkProxyTest.java @@ -0,0 +1,14 @@ +package com.bage.study.java.proxy; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Proxy; + +public class JdkProxyTest { + + public static void main(String[] args) { + + + + } + +} diff --git a/study-jmeter/README-MySQL.md b/study-jmeter/README-MySQL.md new file mode 100644 index 000000000..02b717721 --- /dev/null +++ b/study-jmeter/README-MySQL.md @@ -0,0 +1,84 @@ +# study-jmeter-MySQL # +study-jmeter-MySQL学习笔记 + +## 参考链接 ## + + + +## 简单压测 + +### 数据库压测 + +请求入口 + +http://localhost:8080/mysql/query?key=josh + +数据库连接数 + +``` +登陆 root +mysql -uroot -p + +查看当前最大连接数[默认151?] +show variables like 'max_connections'; + +设置最大连接数 +set global max_connections=10; + +查看当前连接情况 +show status like 'Threads%'; + +``` + + + + + +### 过滤结果 + +只看错误结果树 + +勾选 Error + + + +### 常见错误 + +Jmeter 报错 + +``` +java.net.SocketException: Socket closed + +``` + +解决思路 + +参考链接: https://blog.csdn.net/weixin_44898291/article/details/119023467 + +如果在 HTTP Request Sampler 的 Basic 里勾选了Use KeepAlive,那么建议在 Advanced 页签下: + +1、Implementation 选为 HttpClient4 + +2、Timeouts 中的 Connect 一般设置一个10~60秒的值,表示连接的空闲超时时间,避免由于没收到被压测端的响应回来的 Keep-Alive 的 Header 导致的连接断开 + +这个值的单位是毫秒:15s*1000=15000s + + +Jmeter 报错 + +``` +java.net.SocketException: Too many open files + +``` + +解决思路 + +参考链接: https://www.jianshu.com/p/d6f7d1557f20 + +``` +查看 +launchctl limit + +更新 +sudo launchctl limit maxfiles 4096 unlimited +``` \ No newline at end of file diff --git a/study-jmeter/README.md b/study-jmeter/README.md index cfc0d1d7e..e3cdf3007 100644 --- a/study-jmeter/README.md +++ b/study-jmeter/README.md @@ -1,8 +1,11 @@ # study-jmeter # study-jmeter学习笔记 +MySQL 压力测试: [README-MySQL.md](README-MySQL.md) + ## 参考链接 ## - 官网 [http://jmeter.apache.org/](http://jmeter.apache.org/) +- 中文网 http://www.jmeter.com.cn/ ## 环境搭建 ## 安装jdk后,下载解压直接打开 /bin/jmeter.bat @@ -68,3 +71,6 @@ KB/Sec:每秒从服务器端接收到的数据量,相当于LoadRunner中的T - JMeter Exception: java.net.BindException: Address already in use: connect [http://twit88.com/blog/2008/07/28/jmeter-exception-javanetbindexception-departmentAddress-already-in-use-connect/](http://twit88.com/blog/2008/07/28/jmeter-exception-javanetbindexception-departmentAddress-already-in-use-connect/) - Address already in use : connect 的解决办法 [https://blog.csdn.net/qq_31441637/article/details/80422901](https://blog.csdn.net/qq_31441637/article/details/80422901) + + + diff --git a/study-jmeter/jmx/jmeter-mysql.jmx b/study-jmeter/jmx/jmeter-mysql.jmx new file mode 100644 index 000000000..c6d079024 --- /dev/null +++ b/study-jmeter/jmx/jmeter-mysql.jmx @@ -0,0 +1,235 @@ + + + + + + false + true + false + + + + + + + + continue + + false + 2 + + 2000 + 1 + false + + + true + + + + + + + 127.0.0.1 + 8080 + http + + /mysql/query + GET + true + false + true + false + + HttpClient4 + 60000 + + + + + true + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + + + + + + continue + + false + 2 + + 1000 + 1 + false + + + true + + + + + + + 127.0.0.1 + 8080 + http + + /mysql/insert + POST + true + false + true + false + + HttpClient4 + 60000 + + + + + true + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + + + + + + + diff --git a/study-jmeter/jmx/jmeter-ping.jmx b/study-jmeter/jmx/jmeter-ping.jmx new file mode 100644 index 000000000..4ca95331a --- /dev/null +++ b/study-jmeter/jmx/jmeter-ping.jmx @@ -0,0 +1,206 @@ + + + + + + false + true + false + + + + + + + + continue + + false + 1 + + 1 + 1 + false + + + true + + + + + pang + + + Assertion.response_data + false + 16 + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + + + + + + + + 127.0.0.1 + 8080 + http + + /ping + GET + true + false + true + false + + + + + + + + continue + + false + 3 + + 40 + 3 + false + + + true + + + + + + + 127.0.0.1 + 8080 + http + + /mysql/query + GET + true + false + true + false + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + + + + + + + diff --git a/study-jmeter/pom.xml b/study-jmeter/pom.xml index f9c02bae1..a05928cb4 100644 --- a/study-jmeter/pom.xml +++ b/study-jmeter/pom.xml @@ -15,64 +15,105 @@ http://www.example.com + UTF-8 - 1.7 - 1.7 - + 1.8 + 1.8 + 2.0.1.RELEASE + + 3.4.6 + 1.3.2 + 8.0.13 + + 1.18.20 + + 1.2.12 + 1.4.0 + 1.3.0.Final + + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter + + + org.springframework.boot + spring-boot-starter-test + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + + + + org.mybatis + mybatis + ${mybatis.version} + + + org.mybatis + mybatis-spring + ${mybatis-spring.version} + + + org.mybatis.spring.boot + mybatis-spring-boot-autoconfigure + ${mybatis-spring.version} + + + org.mybatis.spring.boot + mybatis-spring-boot-starter + ${mybatis-spring.version} + + + mysql + mysql-connector-java + ${mysql.version} + + + + + org.mapstruct + mapstruct + ${org.mapstruct.version} + - junit - junit - 4.11 - test + org.mapstruct + mapstruct-jdk8 + ${org.mapstruct.version} + + + + org.projectlombok + lombok + ${lombok.version} + + + + + + + org.springframework.boot + spring-boot-dependencies + ${spring.boot.base.version} + pom + import + + + + - - - - - - maven-clean-plugin - 3.1.0 - - - - maven-resources-plugin - 3.0.2 - - - maven-compiler-plugin - 3.8.0 - - - maven-surefire-plugin - 2.22.1 - - - maven-jar-plugin - 3.0.2 - - - maven-install-plugin - 2.5.2 - - - maven-deploy-plugin - 2.8.2 - - - - maven-site-plugin - 3.7.1 - - - maven-project-info-reports-plugin - 3.0.0 - - - - diff --git a/study-jmeter/src/main/java/com/bage/study/jmeter/AppConstants.java b/study-jmeter/src/main/java/com/bage/study/jmeter/AppConstants.java new file mode 100644 index 000000000..430edd793 --- /dev/null +++ b/study-jmeter/src/main/java/com/bage/study/jmeter/AppConstants.java @@ -0,0 +1,5 @@ +package com.bage.study.jmeter; + +public class AppConstants { + public static final String APP_PREF = "jmeter"; +} diff --git a/study-jmeter/src/main/java/com/bage/study/jmeter/Application.java b/study-jmeter/src/main/java/com/bage/study/jmeter/Application.java new file mode 100644 index 000000000..5fbb9bba4 --- /dev/null +++ b/study-jmeter/src/main/java/com/bage/study/jmeter/Application.java @@ -0,0 +1,17 @@ +package com.bage.study.jmeter; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; + + +@SpringBootApplication( + scanBasePackageClasses = Application.class, + exclude = {DataSourceAutoConfiguration.class} +) +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } +} diff --git a/study-jmeter/src/main/java/com/bage/study/jmeter/Customer.java b/study-jmeter/src/main/java/com/bage/study/jmeter/Customer.java new file mode 100644 index 000000000..fa6100ad2 --- /dev/null +++ b/study-jmeter/src/main/java/com/bage/study/jmeter/Customer.java @@ -0,0 +1,12 @@ +package com.bage.study.jmeter; + +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class Customer { + private long id; + private String firstName, lastName; + +} \ No newline at end of file diff --git a/study-jmeter/src/main/java/com/bage/study/jmeter/PingController.java b/study-jmeter/src/main/java/com/bage/study/jmeter/PingController.java new file mode 100644 index 000000000..2010fb622 --- /dev/null +++ b/study-jmeter/src/main/java/com/bage/study/jmeter/PingController.java @@ -0,0 +1,18 @@ +package com.bage.study.jmeter; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; + +import java.time.LocalDateTime; + +@RestController +public class PingController { + + @RequestMapping("/ping") + public String ping() { + System.out.println(LocalDateTime.now()); + return "pang"; + } + +} diff --git a/study-jmeter/src/main/java/com/bage/study/jmeter/mysql/CustomerRepo.java b/study-jmeter/src/main/java/com/bage/study/jmeter/mysql/CustomerRepo.java new file mode 100644 index 000000000..c0e783f78 --- /dev/null +++ b/study-jmeter/src/main/java/com/bage/study/jmeter/mysql/CustomerRepo.java @@ -0,0 +1,71 @@ +package com.bage.study.jmeter.mysql; + +import com.bage.study.jmeter.Customer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +@Component +public class CustomerRepo { + private static final Logger log = LoggerFactory.getLogger(CustomerRepo.class); + @Autowired + JdbcTemplate jdbcTemplate; + +// @PostConstruct + public void init() { + + log.info("Creating tables"); + +// jdbcTemplate.execute("DROP TABLE customers IF EXISTS"); +// jdbcTemplate.execute("CREATE TABLE customers(" + +// "id SERIAL, first_name VARCHAR(255), last_name VARCHAR(255))"); + + // Split up the array of whole names into an array of first/last names + List splitUpNames = Arrays.asList("John Woo", "Jeff Dean", "Josh Bloch", "Josh Long").stream() + .map(name -> name.split(" ")) + .collect(Collectors.toList()); + + // Use a Java 8 stream to print out each tuple of the list + splitUpNames.forEach(name -> log.info(String.format("Inserting customer record for %s %s", name[0], name[1]))); + + // Uses JdbcTemplate's batchUpdate operation to bulk load data + jdbcTemplate.batchUpdate("INSERT INTO customers(first_name, last_name) VALUES (?,?)", splitUpNames); + + log.info("Querying for customer records where first_name = 'Josh':"); + jdbcTemplate.query( + "SELECT id, first_name, last_name FROM customers WHERE first_name = ?", new Object[]{"Josh"}, + (rs, rowNum) -> new Customer(rs.getLong("id"), rs.getString("first_name"), rs.getString("last_name")) + ).forEach(customer -> log.info(customer.toString())); + } + + public List query(String key) { + return jdbcTemplate.query( + "SELECT id, first_name, last_name FROM customers WHERE first_name = ?", new Object[]{key}, + (rs, rowNum) -> new Customer(rs.getLong("id"), rs.getString("first_name"), rs.getString("last_name")) + ); + } + + public int insert(List list) { + if(Objects.isNull(list)){ + return 0; + } + List splitUpNames = new ArrayList<>(); + + for (Customer customer : list) { + Object[] objs = new Object[2]; + objs[0] = customer.getFirstName(); + objs[1] = customer.getLastName(); + splitUpNames.add(objs); + } + int[] res = jdbcTemplate.batchUpdate("INSERT INTO customers(first_name, last_name) VALUES (?,?)", splitUpNames); + return Arrays.stream(res).sum(); + } +} \ No newline at end of file diff --git a/study-jmeter/src/main/java/com/bage/study/jmeter/mysql/DataSourceConfig.java b/study-jmeter/src/main/java/com/bage/study/jmeter/mysql/DataSourceConfig.java new file mode 100644 index 000000000..e63259a02 --- /dev/null +++ b/study-jmeter/src/main/java/com/bage/study/jmeter/mysql/DataSourceConfig.java @@ -0,0 +1,60 @@ +package com.bage.study.jmeter.mysql; + +import com.bage.study.jmeter.AppConstants; +import com.zaxxer.hikari.HikariDataSource; +import org.apache.ibatis.session.SqlSessionFactory; +import org.mybatis.spring.SqlSessionFactoryBean; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.jdbc.DataSourceBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.Resource; +import org.springframework.core.io.support.PathMatchingResourcePatternResolver; +import org.springframework.jdbc.datasource.DataSourceTransactionManager; + +import javax.sql.DataSource; + +@Configuration +@MapperScan(basePackages = "com.bage.auth.server.*.mapper", sqlSessionFactoryRef = AppConstants.APP_PREF + "SqlSessionFactory") +public class DataSourceConfig { + + + @Bean(AppConstants.APP_PREF + "DataSource") + public DataSource dataSource() { + DataSourceBuilder builder = DataSourceBuilder.create().type(HikariDataSource.class); + HikariDataSource hikariDataSource = builder + .driverClassName("com.mysql.cj.jdbc.Driver") + .url("jdbc:mysql://127.0.0.1:3306/mydb?useSSL=false&characterEncoding=utf8&allowPublicKeyRetrieval=true") + .username("bage") + .password("bage") + .build(); + hikariDataSource.setAutoCommit(true);//update自动提交设置 + hikariDataSource.setConnectionTestQuery("select 1");//连接查询语句设置 + hikariDataSource.setConnectionTimeout(5000);//连接超时时间设置 + hikariDataSource.setIdleTimeout(3000);//连接空闲生命周期设置 + hikariDataSource.setIsolateInternalQueries(false);//执行查询启动设置 + hikariDataSource.setMaximumPoolSize(2);//连接池允许的最大连接数量 + hikariDataSource.setMaxLifetime(1800000);//检查空余连接优化连接池设置时间,单位毫秒 + hikariDataSource.setMinimumIdle(2);//连接池保持最小空余连接数量 + hikariDataSource.setPoolName(AppConstants.APP_PREF + "HikariPool");//连接池名称 +// hikariDataSource.setLogWriter(); + return builder.build(); + } + + @Bean(AppConstants.APP_PREF + "SqlSessionFactory") + public SqlSessionFactory sqlSessionFactory(@Qualifier(AppConstants.APP_PREF + "DataSource") DataSource datasource) throws Exception { + SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean(); + Resource[] resources = new PathMatchingResourcePatternResolver().getResources("classpath*:mapper/com/bage/auth/server/*.xml"); + sqlSessionFactoryBean.setMapperLocations(resources); + sqlSessionFactoryBean.setDataSource(datasource); + return sqlSessionFactoryBean.getObject(); + } + + @Bean(AppConstants.APP_PREF + "TransactionManager") + DataSourceTransactionManager transactionManager(@Qualifier(AppConstants.APP_PREF + "DataSource") DataSource datasource) { + return new DataSourceTransactionManager(datasource); + } + + +} diff --git a/study-jmeter/src/main/java/com/bage/study/jmeter/mysql/MySQLController.java b/study-jmeter/src/main/java/com/bage/study/jmeter/mysql/MySQLController.java new file mode 100644 index 000000000..848226818 --- /dev/null +++ b/study-jmeter/src/main/java/com/bage/study/jmeter/mysql/MySQLController.java @@ -0,0 +1,58 @@ +package com.bage.study.jmeter.mysql; + +import com.bage.study.jmeter.Customer; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.Random; + +@RestController +@RequestMapping("/mysql") +public class MySQLController { + + Random random = new Random(); + @Resource + private CustomerRepo repo; + + @RequestMapping("/query") + public Object query(@RequestParam(required = false) String key) { + if (Objects.isNull(key)) { + key = String.valueOf(System.currentTimeMillis() - random.nextInt()); + } + System.out.println("query:" + LocalDateTime.now() + "; " + key); + return repo.query(key); + } + + @RequestMapping("/insert") + public Object insert(@RequestParam(value = "prefix",required = false) String prefix, + @RequestParam(value = "size",required = false) Integer size) { + if (Objects.isNull(prefix)) { + prefix = String.valueOf(System.currentTimeMillis()); + prefix = prefix.substring(prefix.length() - 10); + } + if (Objects.isNull(size)) { + size = 1; + } + List list = new ArrayList<>(); + for (int i = 0; i < size; i++) { + list.add(new Customer(i, prefix + "" + random.nextInt(100),prefix + "" + random.nextInt(100))); + } + int result = repo.insert(list); + System.out.println("insert:" + "; " + prefix + "; actual = " + result + ", expect = " + list.size()); + return result; + } + + @RequestMapping("/init") + public String init() { + repo.init(); + System.out.println("init:" + LocalDateTime.now()); + return "pang"; + } + +} diff --git a/study-jmockit/coverage-failure.txt b/study-jmockit/coverage-failure.txt new file mode 100644 index 000000000..a2c140e93 --- /dev/null +++ b/study-jmockit/coverage-failure.txt @@ -0,0 +1,17 @@ +java.lang.IllegalStateException: Running on JDK 9 requires -javaagent:/jmockit-1.n.jar or -Djdk.attach.allowAttachSelf + at mockit.internal.startup.AgentLoader.attachToRunningVM(AgentLoader.java:151) + at mockit.internal.startup.AgentLoader.loadAgent(AgentLoader.java:60) + at mockit.internal.startup.Startup.verifyInitialization(Startup.java:137) + at mockit.internal.startup.Startup.instrumentation(Startup.java:130) + at mockit.coverage.modification.ClassModification.redefineClassesAlreadyLoadedForCoverage(ClassModification.java:34) + at mockit.coverage.modification.ClassModification.(ClassModification.java:29) + at mockit.coverage.CodeCoverage.(CodeCoverage.java:52) + at mockit.coverage.CodeCoverage.create(CodeCoverage.java:90) + at mockit.internal.startup.Startup.activateCodeCoverageIfRequested(Startup.java:109) + at mockit.internal.startup.Startup.premain(Startup.java:52) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:491) + at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:503) diff --git a/study-jmockit/pom.xml b/study-jmockit/pom.xml index 66cf3872c..85130b5ae 100644 --- a/study-jmockit/pom.xml +++ b/study-jmockit/pom.xml @@ -16,8 +16,8 @@ UTF-8 - 1.7 - 1.7 + 1.8 + 1.8 diff --git a/study-jmockit/src/test/java/com/bage/jmockit/HelloJMockitTest.java b/study-jmockit/src/test/java/com/bage/jmockit/HelloJMockitTest.java index 8efe57515..bacd18e14 100644 --- a/study-jmockit/src/test/java/com/bage/jmockit/HelloJMockitTest.java +++ b/study-jmockit/src/test/java/com/bage/jmockit/HelloJMockitTest.java @@ -3,10 +3,13 @@ import mockit.Expectations; import mockit.Mocked; import mockit.Verifications; +import mockit.integration.junit4.JMockit; import org.junit.Assert; import org.junit.Test; +import org.junit.runner.RunWith; //HelloJMockit类的测试类 +@RunWith(JMockit.class) public class HelloJMockitTest { // 这是一个测试属性 diff --git a/study-jmockit/src/test/java/com/bage/jmockit/HelloServiceTest.java b/study-jmockit/src/test/java/com/bage/jmockit/HelloServiceTest.java index 479dcc931..cdda15295 100644 --- a/study-jmockit/src/test/java/com/bage/jmockit/HelloServiceTest.java +++ b/study-jmockit/src/test/java/com/bage/jmockit/HelloServiceTest.java @@ -1,31 +1,30 @@ package com.bage.jmockit; -import mockit.Expectations; -import mockit.Mocked; -import mockit.Verifications; +import mockit.*; import org.junit.Assert; import org.junit.Test; //HelloJMockit类的测试类 public class HelloServiceTest { - @Mocked + @Tested HelloService helloService; - @Mocked + @Injectable HelloJMockit helloJMockit; @Test - public void test() { + public void test(final @Mocked HelloJMockit target) { // 录制(Record) new Expectations() { { - helloJMockit.sayHello(); + target.sayHello(); // 期待上述调用的返回是"hello,david",而不是返回"hello,JMockit" result = "hello,david"; } }; // 重放(Replay) String msg = helloService.sayHello(); + System.out.println(msg); Assert.assertTrue(msg.equals("hello,david")); // 验证(Verification) new Verifications() { diff --git a/study-jol/README.md b/study-jol/README.md new file mode 100644 index 000000000..edd2a2451 --- /dev/null +++ b/study-jol/README.md @@ -0,0 +1,9 @@ +# study-jol # + +## 参考链接 ## +- Jol https://github.com/openjdk/jol + + + + + diff --git a/study-jol/pom.xml b/study-jol/pom.xml new file mode 100644 index 000000000..43cad8ce7 --- /dev/null +++ b/study-jol/pom.xml @@ -0,0 +1,84 @@ + + + + 4.0.0 + + com.bage + study-jol + 0.0.1-SNAPSHOT + + study-jol + + http://www.example.com + + + UTF-8 + 1.8 + 1.8 + 0.16 + + + + + junit + junit + 4.11 + test + + + + org.openjdk.jol + jol-core + ${jol.api.version} + + + + + + + + + + + maven-clean-plugin + 3.1.0 + + + + maven-resources-plugin + 3.0.2 + + + maven-compiler-plugin + 3.8.0 + + + maven-surefire-plugin + 2.22.1 + + + maven-jar-plugin + 3.0.2 + + + maven-install-plugin + 2.5.2 + + + maven-deploy-plugin + 2.8.2 + + + + maven-site-plugin + 3.7.1 + + + maven-project-info-reports-plugin + 3.0.0 + + + + + diff --git a/study-jol/src/main/java/com/bage/JOLSample_01_Basic.java b/study-jol/src/main/java/com/bage/JOLSample_01_Basic.java new file mode 100644 index 000000000..016bd47d9 --- /dev/null +++ b/study-jol/src/main/java/com/bage/JOLSample_01_Basic.java @@ -0,0 +1,30 @@ +package com.bage; + +import org.openjdk.jol.info.ClassLayout; +import org.openjdk.jol.vm.VM; + +import static java.lang.System.out; + +/** + * @author Aleksey Shipilev + */ +public class JOLSample_01_Basic { + + /* + * This sample showcases the basic field layout. + * You can see a few notable things here: + * a) how much the object header consumes; + * b) how fields are laid out; + * c) how the external alignment beefs up the object size + */ + + public static void main(String[] args) { + out.println(VM.current().details()); + out.println(ClassLayout.parseClass(A.class).toPrintable()); + } + + public static class A { + boolean f; + } + +} \ No newline at end of file diff --git a/study-jmeter/src/test/java/com/bage/AppTest.java b/study-jol/src/test/java/com/bage/AppTest.java similarity index 100% rename from study-jmeter/src/test/java/com/bage/AppTest.java rename to study-jol/src/test/java/com/bage/AppTest.java diff --git a/study-jpush/pom.xml b/study-jpush/pom.xml index a51455cfa..50c37e854 100644 --- a/study-jpush/pom.xml +++ b/study-jpush/pom.xml @@ -14,6 +14,8 @@ http://maven.apache.org UTF-8 + 1.8 + 1.8 diff --git a/study-json-to-pojo/pom.xml b/study-json-to-pojo/pom.xml index 314ed6d9b..0b5e02bf5 100644 --- a/study-json-to-pojo/pom.xml +++ b/study-json-to-pojo/pom.xml @@ -17,8 +17,8 @@ UTF-8 - 1.7 - 1.7 + 1.8 + 1.8 @@ -35,19 +35,18 @@ 1.0.0 - - - org.json - JSON-Java - 1.2 - jar - junit junit 4.12 compile + + org.json + json + 20160810 + compile + diff --git a/study-json/pom.xml b/study-json/pom.xml index e2eb8cc6a..f28f2062b 100644 --- a/study-json/pom.xml +++ b/study-json/pom.xml @@ -29,8 +29,8 @@ UTF-8 - 1.7 - 1.7 + 1.8 + 1.8 diff --git a/study-jvm/pom.xml b/study-jvm/pom.xml index 32afc7868..ddec8f88c 100644 --- a/study-jvm/pom.xml +++ b/study-jvm/pom.xml @@ -32,8 +32,8 @@ UTF-8 - 1.7 - 1.7 + 1.8 + 1.8 diff --git a/study-jvm/src/main/java/SimpleDebugger.java b/study-jvm/src/main/java/SimpleDebugger.java index a8206a9ad..cf998ec44 100644 --- a/study-jvm/src/main/java/SimpleDebugger.java +++ b/study-jvm/src/main/java/SimpleDebugger.java @@ -1,3 +1,4 @@ + import com.sun.jdi.*; import com.sun.jdi.connect.Connector; import com.sun.jdi.connect.LaunchingConnector; diff --git a/study-jwt/pom.xml b/study-jwt/pom.xml index 7ab19f4c1..689e8fb04 100644 --- a/study-jwt/pom.xml +++ b/study-jwt/pom.xml @@ -14,6 +14,8 @@ UTF-8 + 1.8 + 1.8 2.0.1.RELEASE 3.4.6 1.3.2 diff --git a/study-leancloud/pom.xml b/study-leancloud/pom.xml index fccc0246b..37534cc17 100644 --- a/study-leancloud/pom.xml +++ b/study-leancloud/pom.xml @@ -17,8 +17,8 @@ UTF-8 - 1.7 - 1.7 + 1.8 + 1.8 diff --git a/study-log-logback/README.md b/study-log-logback/README.md index 81fd25bae..600cec8a0 100644 --- a/study-log-logback/README.md +++ b/study-log-logback/README.md @@ -1,6 +1,8 @@ # study-log-logback # logback 基本使用 +todo: setRules null + ## 参考链接 ## @@ -9,7 +11,8 @@ logback 基本使用 - demo [http://github.com/qos-ch/logback-demo](http://github.com/qos-ch/logback-demo) - How to setup SLF4J and LOGBack in a web app - fast [https://wiki.base22.com/btg/how-to-setup-slf4j-and-logback-in-a-web-app-fast-35488048.html](https://wiki.base22.com/btg/how-to-setup-slf4j-and-logback-in-a-web-app-fast-35488048.html) - Mapped Diagnostic Context [https://logback.qos.ch/manual/mdc.html](https://logback.qos.ch/manual/mdc.html) - +- 日志过滤 https://www.baeldung.com/logback-mask-sensitive-data +- 日志过滤 https://github.com/premanandc/masking-logback-json-provider ## 环境搭建 ## 添加logback依赖 diff --git a/study-log-logback/pom.xml b/study-log-logback/pom.xml index a62848b14..02b3c2ed1 100644 --- a/study-log-logback/pom.xml +++ b/study-log-logback/pom.xml @@ -12,7 +12,9 @@ http://maven.apache.org UTF-8 - 1.0.13 + 1.8 + 1.8 + 1.2.3 @@ -44,5 +46,11 @@ test + + net.logstash.logback + logstash-logback-encoder + 4.11 + + diff --git a/study-log-logback/src/main/java/com/bage/study/log/logback/MaskingPatternLayout.java b/study-log-logback/src/main/java/com/bage/study/log/logback/MaskingPatternLayout.java new file mode 100644 index 000000000..3372d623b --- /dev/null +++ b/study-log-logback/src/main/java/com/bage/study/log/logback/MaskingPatternLayout.java @@ -0,0 +1,47 @@ +package com.bage.study.log.logback; + +import ch.qos.logback.classic.PatternLayout; +import ch.qos.logback.classic.spi.ILoggingEvent; + +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +public class MaskingPatternLayout extends PatternLayout { + + private Pattern multilinePattern; + private List maskPatterns = new ArrayList<>(); + + public void addMaskPattern(String maskPattern) { + maskPatterns.add(maskPattern); + multilinePattern = Pattern.compile(maskPatterns.stream().collect(Collectors.joining("|")), Pattern.MULTILINE); + } + +// @Override +// public String doLayout(IAccessEvent event) { +// return super.doLayout(event); +// } + + @Override + public String doLayout(ILoggingEvent event) { + return maskMessage(super.doLayout(event)); + } + private String maskMessage(String message) { + if (multilinePattern == null) { + return message; + } + StringBuilder sb = new StringBuilder(message); + Matcher matcher = multilinePattern.matcher(sb); + while (matcher.find()) { + IntStream.rangeClosed(1, matcher.groupCount()).forEach(group -> { + if (matcher.group(group) != null) { + IntStream.range(matcher.start(group), matcher.end(group)).forEach(i -> sb.setCharAt(i, '*')); + } + }); + } + return sb.toString(); + } +} diff --git a/study-log-logback/src/main/java/com/bage/study/log/logback/mask/MaskRule.java b/study-log-logback/src/main/java/com/bage/study/log/logback/mask/MaskRule.java new file mode 100644 index 000000000..81759f97a --- /dev/null +++ b/study-log-logback/src/main/java/com/bage/study/log/logback/mask/MaskRule.java @@ -0,0 +1,148 @@ +package com.bage.study.log.logback.mask; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import static java.util.regex.Pattern.DOTALL; +import static java.util.regex.Pattern.MULTILINE; +import static java.util.regex.Pattern.compile; + +/** + * Rule to masks sensitive information in logs. + */ +public class MaskRule { + private final String name; + private final Pattern pattern; + private final int unmasked; + + /** + * + * @param name a friendly name for the rule. + * @param prefix a literal prefix preceding the actual search pattern. + * @param suffix a literal suffix preceding the actual search pattern. + * @param pattern a regular expression pattern to identify the personally identifiable information. + * @param unmasked the number of characters to leave unmasked. + */ + MaskRule(String name, String prefix, String suffix, String pattern, int unmasked) { + this.name = parse(name); + this.pattern = parse(prefix, suffix, pattern); + this.unmasked = unmasked; + } + + private String parse(String name) { + if (nullOrBlank(name)) { + throw new IllegalArgumentException("Name cannot be null blank!"); + } + return name.trim(); + } + + private static String repeat(String input, int times) { + if (times <= 0) return ""; + else if (times % 2 == 0) return repeat(input + input, times / 2); + else return input + repeat(input + input, times / 2); + } + + private static Pattern parse(String prefix, String suffix, String pattern) { + String parsedPrefix = nullOrBlank(prefix) ? "" : "(?<=" + prefix + ")(?:\\s*)"; + String parsedSuffix = nullOrBlank(suffix) ? "" : "(?:\\s*)(?=" + suffix + ")"; + return compile(parsedPrefix + validated(pattern) + parsedSuffix, DOTALL | MULTILINE); + } + + private static String validated(String pattern) { + if (nullOrBlank(pattern)) { + throw new IllegalArgumentException("Need a non-blank pattern value!"); + } + return pattern.startsWith("(") ? pattern : "(" + pattern + ")"; + } + + private static boolean nullOrBlank(String input) { + return input == null || "".equals(input.trim()); + } + + /** + * Applies the masking rule to the input. + * @param input the PII that needs to be masked. + * @return the masked version of the input. + */ + public String apply(String input) { + Matcher matcher = pattern.matcher(input); + if (matcher.find()) { + String match = matcher.group(1); + String mask = repeat("X", Math.min(match.length(), match.length() - unmasked)); + String replacement = mask + match.substring(mask.length()); + return input.replace(match, replacement); + } + return input; + } + + /** + * Helper to create a new rule instance. + * @see MaskRule + * @see ch.qos.logback.classic.joran.JoranConfigurator + */ + + + public static class Definition { + private String name; + private String prefix = ""; + private String suffix = ""; + private String pattern; + private int unmasked = 0; + + public Definition(String name, String pattern) { + this(name, "", "", pattern, 0); + } + + public Definition(String name, String prefix, String suffix, String pattern, int unmasked) { + this.name = name; + this.prefix = prefix; + this.suffix = suffix; + this.pattern = pattern; + this.unmasked = unmasked; + } + + public MaskRule rule() { + return new MaskRule(name, prefix, suffix, pattern, unmasked); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPrefix() { + return prefix; + } + + public void setPrefix(String prefix) { + this.prefix = prefix; + } + + public String getSuffix() { + return suffix; + } + + public void setSuffix(String suffix) { + this.suffix = suffix; + } + + public String getPattern() { + return pattern; + } + + public void setPattern(String pattern) { + this.pattern = pattern; + } + + public int getUnmasked() { + return unmasked; + } + + public void setUnmasked(int unmasked) { + this.unmasked = unmasked; + } + } +} \ No newline at end of file diff --git a/study-log-logback/src/main/java/com/bage/study/log/logback/mask/MaskRules.java b/study-log-logback/src/main/java/com/bage/study/log/logback/mask/MaskRules.java new file mode 100644 index 000000000..c200ec146 --- /dev/null +++ b/study-log-logback/src/main/java/com/bage/study/log/logback/mask/MaskRules.java @@ -0,0 +1,21 @@ +package com.bage.study.log.logback.mask; + +import java.util.LinkedHashSet; +import java.util.Set; +import java.util.function.BinaryOperator; + +public class MaskRules { + private static final BinaryOperator NO_OP = (in, out) -> { + throw new UnsupportedOperationException("Only needed for parallel streams!"); + }; + + private final Set rules = new LinkedHashSet<>(); + + public void addRule(MaskRule.Definition definition) { + rules.add(definition.rule()); + } + + public String apply(String input) { + return rules.stream().reduce(input, (out, rule) -> rule.apply(out), NO_OP); + } +} \ No newline at end of file diff --git a/study-log-logback/src/main/java/com/bage/study/log/logback/mask/MaskingMessageProvider.java b/study-log-logback/src/main/java/com/bage/study/log/logback/mask/MaskingMessageProvider.java new file mode 100644 index 000000000..707bbdef6 --- /dev/null +++ b/study-log-logback/src/main/java/com/bage/study/log/logback/mask/MaskingMessageProvider.java @@ -0,0 +1,22 @@ +package com.bage.study.log.logback.mask; + +import ch.qos.logback.classic.spi.ILoggingEvent; +import com.fasterxml.jackson.core.JsonGenerator; +import net.logstash.logback.composite.JsonWritingUtils; +import net.logstash.logback.composite.loggingevent.MessageJsonProvider; + +import java.io.IOException; + +public class MaskingMessageProvider extends MessageJsonProvider { + + private MaskRules rules; + + @Override + public void writeTo(JsonGenerator generator, ILoggingEvent event) throws IOException { + JsonWritingUtils.writeStringField(generator, getFieldName(), rules.apply(event.getFormattedMessage())); + } + + public void setRules(MaskRules rules) { + this.rules = rules; + } +} \ No newline at end of file diff --git a/study-log-logback/src/main/resources/logback-test.xml b/study-log-logback/src/main/resources/logback-test.xml deleted file mode 100644 index 654a771bf..000000000 --- a/study-log-logback/src/main/resources/logback-test.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - %X{myTag} %d{HH:mm:ss.SSS} [%thread] %-5level %logger{32} - %msg%n - - - - - - - logFile.log - - - logFile.%d{yyyy-MM-dd_HH-mm}.log.zip - - - - - - %d{HH:mm:ss,SSS} [%thread] %-5level %logger{32} - %msg%n - - - - - - - - - - - - - - \ No newline at end of file diff --git a/study-log-logback/src/main/resources/logback.xml b/study-log-logback/src/main/resources/logback.xml index bd3d85a7d..625744c54 100644 --- a/study-log-logback/src/main/resources/logback.xml +++ b/study-log-logback/src/main/resources/logback.xml @@ -11,6 +11,40 @@ %X{myTag} %d{HH:mm:ss.SSS} [%thread] %-5level %logger{32} - %msg%n + + + + + UTC + + + + + ssn + \d{3}-?\d{2}-?\d{4} + + + + + + + { + "severity": "%level", + "thread": "%thread", + "class": "%logger{40}" + } + + + + + + + + \"ssn\"\s*:\s*\"(.*?)\" + \"email\"\s*:\s*\"(.*?)\" + + + diff --git a/study-log-logback/src/test/java/com/bage/study/log/logback/LogAppTest.java b/study-log-logback/src/test/java/com/bage/study/log/logback/LogAppTest.java index aea114717..df07015a3 100644 --- a/study-log-logback/src/test/java/com/bage/study/log/logback/LogAppTest.java +++ b/study-log-logback/src/test/java/com/bage/study/log/logback/LogAppTest.java @@ -22,4 +22,5 @@ public void test() { LOG.error("I am programming."); } + } diff --git a/study-log-logback/src/test/java/com/bage/study/log/logback/MaskLogTest.java b/study-log-logback/src/test/java/com/bage/study/log/logback/MaskLogTest.java new file mode 100644 index 000000000..f42d14e28 --- /dev/null +++ b/study-log-logback/src/test/java/com/bage/study/log/logback/MaskLogTest.java @@ -0,0 +1,28 @@ +package com.bage.study.log.logback; + +// Add the following to the imports section of your java code: +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * LogAppTest + */ +public class MaskLogTest { + + private static final Logger LOG = LoggerFactory.getLogger(MaskLogTest.class); + + + @org.junit.Test + public void testMasking() { + // Throw some logging statements in your code somewhere where you know they'll be fired right away when you run your app. For example: + String json = "{\n" + + " \"user_id\":\"87656\",\n" + + " \"ssn\":\"123-12-3453\",\n" + + " \"city\":\"Chicago\",\n" + + " \"Country\":\"U.S.\",\n" + + " \"email\":\"bage@qq.com\"\n" + + " }"; + LOG.info(json); + } + +} diff --git a/study-log-logback/src/test/resources/logback-test.xml b/study-log-logback/src/test/resources/logback-test.xml new file mode 100644 index 000000000..97c3f7b9a --- /dev/null +++ b/study-log-logback/src/test/resources/logback-test.xml @@ -0,0 +1,123 @@ + + + + + + + + + + + UTC + + + + + ssn + \d{3}-?\d{2}-?\d{4} + + + + + + + { + "severity": "%level", + "thread": "%thread", + "class": "%logger{40}" + } + + + + + + + + + + + + UTC + + + + + ssn + \d{3}-?\d{2}-?\d{4} + + + + + + + { + "severity": "%level", + "thread": "%thread", + "class": "%logger{40}" + } + + + + + + + + + + + + \"ssn\"\s*:\s*\"(.*?)\" + \"email\"\s*:\s*\"(.*?)\" + + %X{myTag} %d{HH:mm:ss.SSS} [%thread] %-5level %logger{32} - %msg%n + + + + + + + logFile.log + + + logFile.%d{yyyy-MM-dd_HH-mm}.log.zip + + + + + + %d{HH:mm:ss,SSS} [%thread] %-5level %logger{32} - %msg%n + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/study-log4j2/pom.xml b/study-log4j2/pom.xml index 79a121078..06978a3e0 100644 --- a/study-log4j2/pom.xml +++ b/study-log4j2/pom.xml @@ -12,6 +12,8 @@ http://maven.apache.org UTF-8 + 1.8 + 1.8 1.8 1.8 diff --git a/study-lombok/pom.xml b/study-lombok/pom.xml index 9891c8d2e..0c674f735 100644 --- a/study-lombok/pom.xml +++ b/study-lombok/pom.xml @@ -12,6 +12,8 @@ http://maven.apache.org UTF-8 + 1.8 + 1.8 @@ -24,8 +26,8 @@ org.projectlombok lombok - 1.16.18 - provided + 1.18.20 + provided diff --git a/study-lombok/src/main/java/com/bage/study/lombok/App.java b/study-lombok/src/main/java/com/bage/study/lombok/App.java deleted file mode 100644 index 27e6f661d..000000000 --- a/study-lombok/src/main/java/com/bage/study/lombok/App.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.bage.study.lombok; - -import lombok.val; - -import java.util.HashSet; - -/** - * Hello world! - * - */ -public class App -{ - public static void main( String[] args ) - { - val sets = new HashSet(); - - sets = new HashSet(); - - System.out.println(new User("id","name").getId()); - System.out.println( "Hello World!" ); - } -} diff --git a/study-lombok/src/main/java/com/bage/study/lombok/UserAccess.java b/study-lombok/src/main/java/com/bage/study/lombok/UserAccess.java new file mode 100644 index 000000000..699dc1829 --- /dev/null +++ b/study-lombok/src/main/java/com/bage/study/lombok/UserAccess.java @@ -0,0 +1,13 @@ +package com.bage.study.lombok; + +import lombok.*; +import lombok.experimental.Accessors; + +@Data +@Accessors(fluent = true) +public class UserAccess { + + private String id; + private String name; + +} diff --git a/study-lombok/src/test/java/com/bage/study/lombok/AppTest.java b/study-lombok/src/test/java/com/bage/study/lombok/AppTest.java deleted file mode 100644 index 500356155..000000000 --- a/study-lombok/src/test/java/com/bage/study/lombok/AppTest.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.bage.study.lombok; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -/** - * Unit test for simple App. - */ -public class AppTest - extends TestCase -{ - /** - * Create the test case - * - * @param testName name of the test case - */ - public AppTest( String testName ) - { - super( testName ); - } - - /** - * @return the suite of tests being tested - */ - public static Test suite() - { - return new TestSuite( AppTest.class ); - } - - /** - * Rigourous Test :-) - */ - public void testApp() - { - assertTrue( true ); - } -} diff --git a/study-lombok/src/test/java/com/bage/study/lombok/UserAccessTest.java b/study-lombok/src/test/java/com/bage/study/lombok/UserAccessTest.java new file mode 100644 index 000000000..9b8b76031 --- /dev/null +++ b/study-lombok/src/test/java/com/bage/study/lombok/UserAccessTest.java @@ -0,0 +1,14 @@ +package com.bage.study.lombok; + +import junit.framework.TestCase; + +/** + * Unit test for simple App. + */ +public class UserAccessTest extends TestCase { + public void testApp(){ + UserAccess userAccess = new UserAccess(); + userAccess.id("id").name("name"); + System.out.println(userAccess); + } +} diff --git a/study-lombok/src/test/java/com/bage/study/lombok/UserTest.java b/study-lombok/src/test/java/com/bage/study/lombok/UserTest.java new file mode 100644 index 000000000..26d8d3140 --- /dev/null +++ b/study-lombok/src/test/java/com/bage/study/lombok/UserTest.java @@ -0,0 +1,13 @@ +package com.bage.study.lombok; + +import junit.framework.TestCase; + +/** + * Unit test for simple App. + */ +public class UserTest extends TestCase { + public void testApp(){ + String id = new User().getId(); + System.out.println(id); + } +} diff --git a/study-m3u/pom.xml b/study-m3u/pom.xml index 090e62dea..5a1348fbd 100644 --- a/study-m3u/pom.xml +++ b/study-m3u/pom.xml @@ -25,8 +25,9 @@ UTF-8 - 1.7 - 1.7 + 1.8 + 1.8 + @@ -67,7 +68,7 @@ org.projectlombok lombok - 1.16.10 + 1.18.20 diff --git a/study-mapping-generator/pom.xml b/study-mapping-generator/pom.xml index 9ed5d567a..a59e55a87 100644 --- a/study-mapping-generator/pom.xml +++ b/study-mapping-generator/pom.xml @@ -16,6 +16,8 @@ UTF-8 + 1.8 + 1.8 1.7 1.7 diff --git a/study-materialize-spring-boot/pom.xml b/study-materialize-spring-boot/pom.xml index a9ea33049..b2d6e4278 100644 --- a/study-materialize-spring-boot/pom.xml +++ b/study-materialize-spring-boot/pom.xml @@ -12,6 +12,8 @@ http://maven.apache.org UTF-8 + 1.8 + 1.8 2.0.1.RELEASE 3.4.6 1.3.2 diff --git a/study-maven/src/main/java/cn/home/maventool/Main.java b/study-maven/src/main/java/cn/home/maventool/Main.java index e8e2e7946..67507bcf4 100644 --- a/study-maven/src/main/java/cn/home/maventool/Main.java +++ b/study-maven/src/main/java/cn/home/maventool/Main.java @@ -11,7 +11,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import sun.misc.JarFilter; /** * @author lihzh-home @@ -38,20 +37,20 @@ public static void main(String[] args) { _log.warn("The path must be a directory."); return; } - FilenameFilter filter = new JarFilter(); - File[] jarFiles = file.listFiles(filter); - for(File jar: jarFiles){ - installJarToMaven(jar); - if(isDelete){ - _log.info("Delete the original jar file ["+jar.getName()+"]."); - jar.delete(); - }else{ - if(isMove){ - String backupPath = propHelper.getValue(KEY_BACKUPPATH); - backupJar(jar,file,backupPath); - } - } - } +// FilenameFilter filter = new JarFilter(); +// File[] jarFiles = file.listFiles(filter); +// for(File jar: jarFiles){ +// installJarToMaven(jar); +// if(isDelete){ +// _log.info("Delete the original jar file ["+jar.getName()+"]."); +// jar.delete(); +// }else{ +// if(isMove){ +// String backupPath = propHelper.getValue(KEY_BACKUPPATH); +// backupJar(jar,file,backupPath); +// } +// } +// } } private static void backupJar(File jar, File file, String backupPath) { diff --git a/study-mockito/pom.xml b/study-mockito/pom.xml index 6c367c9e6..8da4dfff4 100644 --- a/study-mockito/pom.xml +++ b/study-mockito/pom.xml @@ -14,6 +14,8 @@ UTF-8 + 1.8 + 1.8 2.0.1.RELEASE diff --git a/study-mongodb/pom.xml b/study-mongodb/pom.xml index c118b2443..9cc537db3 100644 --- a/study-mongodb/pom.xml +++ b/study-mongodb/pom.xml @@ -15,6 +15,8 @@ UTF-8 + 1.8 + 1.8 2.0.1.RELEASE diff --git a/study-mybatis-generator-maven-plugin/pom.xml b/study-mybatis-generator-maven-plugin/pom.xml index d520c4ee7..88770cd5c 100644 --- a/study-mybatis-generator-maven-plugin/pom.xml +++ b/study-mybatis-generator-maven-plugin/pom.xml @@ -17,6 +17,8 @@ UTF-8 + 1.8 + 1.8 1.7 1.7 diff --git a/study-mybatis/pom.xml b/study-mybatis/pom.xml index 5004e0322..c4b247daf 100644 --- a/study-mybatis/pom.xml +++ b/study-mybatis/pom.xml @@ -99,7 +99,7 @@ org.projectlombok lombok - 1.16.18 + 1.18.20 provided @@ -117,7 +117,7 @@ - + diff --git a/study-obj-mapper/pom.xml b/study-obj-mapper/pom.xml index 6afeb9cba..0848bb3b8 100644 --- a/study-obj-mapper/pom.xml +++ b/study-obj-mapper/pom.xml @@ -17,8 +17,8 @@ UTF-8 - 1.7 - 1.7 + 1.8 + 1.8 1.3.0.Final diff --git a/study-quartz/pom.xml b/study-quartz/pom.xml index 43b0ce59f..5e9d65afd 100644 --- a/study-quartz/pom.xml +++ b/study-quartz/pom.xml @@ -71,6 +71,7 @@ org.projectlombok lombok + 1.18.20 true diff --git a/study-redis/README.md b/study-redis/README.md index 628d476a4..e7beef239 100644 --- a/study-redis/README.md +++ b/study-redis/README.md @@ -84,7 +84,7 @@ redis采用的是定期删除+惰性删除策略 192.168.127.128:6379>exists name age departmentAddress(该值存在) (integer)2 - + 192.168.127.128:6379>exists name1 age1 departmentAddress(该值存在) (integer)0 - 语法:flushdb,清空当前数据所有的键值对。 @@ -140,7 +140,7 @@ redis采用的是定期删除+惰性删除策略 port 6379 4. 绑定的主机地址 bind 127.0.0.1 -5.当 客户端闲置多长时间后关闭连接,如果指定为0,表示关闭该功能 + 5.当 客户端闲置多长时间后关闭连接,如果指定为0,表示关闭该功能 timeout 300 6. 指定日志记录级别,Redis总共支持四个级别:debug、verbose、notice、warning,默认为verbose loglevel verbose @@ -155,7 +155,7 @@ redis采用的是定期删除+惰性删除策略 save 300 10 save 60 10000 分别表示900秒(15分钟)内有1个更改,300秒(5分钟)内有10个更改以及60秒内有10000个更改。 - + 10. 指定存储至本地数据库时是否压缩数据,默认为yes,Redis采用LZF压缩,如果为了节省CPU时间,可以关闭该选项,但会导致数据库文件变的巨大 rdbcompression yes 11. 指定本地数据库文件名,默认值为dump.rdb @@ -181,7 +181,7 @@ redis采用的是定期删除+惰性删除策略 always:表示每次更新操作后手动调用fsync()将数据写到磁盘(慢,安全) everysec:表示每秒同步一次(折衷,默认值) appendfsync everysec - + 21. 指定是否启用虚拟内存机制,默认值为no,简单的介绍一下,VM机制将数据分页存放,由Redis将访问量较少的页即冷数据swap到磁盘上,访问多的页面由磁盘自动换出到内存中(在后面的文章我会仔细分析Redis的VM机制) vm-enabled no 22. 虚拟内存文件路径,默认值为/tmp/redis.swap,不可多个Redis实例共享 @@ -233,3 +233,30 @@ Codis一个比较大的优点是可以不停机动态新增或删除数据节点 客户端分片 +## 慢查询日志 ## + +### 设置慢日志时间阈值 + +### 查询慢查询日志 + +### 扫描大Key + +需要注意的是当我们在线上实例进行大key扫描时,Redis的QPS会突增,为了降低扫描过程中对Redis的影响,我们需要控制扫描的频率,使用-i参数控制即可,它表示扫描过程中每次扫描的时间间隔,单位是秒。 + +### 大量key集中过期 + +有时你会发现,平时在使用Redis时没有延时比较大的情况,但在某个时间点突然出现一波延时,而且报慢的时间点很有规律,例如某个整点,或者间隔多久就会发生一次。 + +如果出现这种情况,就需要考虑是否存在大量key集中过期的情况 + +### **实例内存达到上限** + +实例的内存达到了maxmemory后,你会发现之后的每次写入新的数据,有可能变慢了。 + +导致变慢的原因是,当Redis内存达到maxmemory后,每次写入新的数据之前,必须先踢出一部分数据,让内存维持在maxmemory之下。 + +这个踢出旧数据的逻辑也是需要消耗时间的,而具体耗时的长短,要取决于配置的淘汰策略: + +### **fork耗时严重** + +执行生成RDB和AOF重写任务导致的。 diff --git a/study-regex/pom.xml b/study-regex/pom.xml index bcdeefccd..328468e33 100644 --- a/study-regex/pom.xml +++ b/study-regex/pom.xml @@ -17,8 +17,8 @@ UTF-8 - 1.7 - 1.7 + 1.8 + 1.8 diff --git a/study-security/README-security.md b/study-security/README-security.md index 54ee88133..0b33c51ee 100644 --- a/study-security/README-security.md +++ b/study-security/README-security.md @@ -1,8 +1,6 @@ # Web Security # -Web 应用安全 - -很重要!!! +Web 应用安全,,,很重要!!! ## 安全类型 ## @@ -166,5 +164,7 @@ sign 签名,请求无法进行伪造 - 不安全的反序列化漏洞 ## 参考链接 ## +- https://github.com/CHYbeta/Web-Security-Learning - security-guide-for-developers -[https://github.com/FallibleInc/security-guide-for-developers](https://github.com/FallibleInc/security-guide-for-developers "security-guide-for-developers") \ No newline at end of file +[https://github.com/FallibleInc/security-guide-for-developers](https://github.com/FallibleInc/security-guide-for-developers "security-guide-for-developers") +- https://github.com/qazbnm456/awesome-web-security/blob/master/README-zh.md diff --git a/study-security/pom.xml b/study-security/pom.xml index ed86babb6..df5194a1f 100644 --- a/study-security/pom.xml +++ b/study-security/pom.xml @@ -14,6 +14,8 @@ http://maven.apache.org UTF-8 + 1.8 + 1.8 4.3.9.RELEASE UTF-8 3.1.0 diff --git a/study-servlet/pom.xml b/study-servlet/pom.xml new file mode 100644 index 000000000..9cbf20ed1 --- /dev/null +++ b/study-servlet/pom.xml @@ -0,0 +1,88 @@ + + + + + study + com.bage + 0.0.1-SNAPSHOT + + 4.0.0 + + study-servlet + + study-servlet + http://www.example.com + + + UTF-8 + 1.8 + 1.8 + + + + + junit + junit + 4.11 + test + + + + + javax.servlet + servlet-api + 3.0-alpha-1 + provided + + + + + + + + + + + + maven-clean-plugin + 3.1.0 + + + + maven-resources-plugin + 3.0.2 + + + maven-compiler-plugin + 3.8.0 + + + maven-surefire-plugin + 2.22.1 + + + maven-jar-plugin + 3.0.2 + + + maven-install-plugin + 2.5.2 + + + maven-deploy-plugin + 2.8.2 + + + + maven-site-plugin + 3.7.1 + + + maven-project-info-reports-plugin + 3.0.0 + + + + + diff --git a/study-jmeter/src/main/java/com/bage/App.java b/study-servlet/src/main/java/com/bage/App.java similarity index 100% rename from study-jmeter/src/main/java/com/bage/App.java rename to study-servlet/src/main/java/com/bage/App.java diff --git a/study-servlet/src/main/java/com/bage/HelloServlet.java b/study-servlet/src/main/java/com/bage/HelloServlet.java new file mode 100644 index 000000000..bdd283c84 --- /dev/null +++ b/study-servlet/src/main/java/com/bage/HelloServlet.java @@ -0,0 +1,27 @@ +package com.bage; + +import javax.servlet.ServletException; +import javax.servlet.SingleThreadModel; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +/** + * SingleThreadModel 支持每个请求单独一个类实现, 不过不推荐 + */ + +public class HelloServlet extends HttpServlet implements SingleThreadModel { + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + + System.out.println("HelloServlet xxxx"); + + } + + @Override + protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + super.doGet(req, resp); + } +} diff --git a/study-servlet/src/test/java/com/bage/AppTest.java b/study-servlet/src/test/java/com/bage/AppTest.java new file mode 100644 index 000000000..9216cfd04 --- /dev/null +++ b/study-servlet/src/test/java/com/bage/AppTest.java @@ -0,0 +1,20 @@ +package com.bage; + +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +/** + * Unit test for simple App. + */ +public class AppTest +{ + /** + * Rigorous Test :-) + */ + @Test + public void shouldAnswerWithTrue() + { + assertTrue( true ); + } +} diff --git a/study-sftp/pom.xml b/study-sftp/pom.xml index 905257fe8..98b214014 100644 --- a/study-sftp/pom.xml +++ b/study-sftp/pom.xml @@ -28,8 +28,8 @@ UTF-8 - 1.7 - 1.7 + 1.8 + 1.8 diff --git a/study-shiro-spring-boot/pom.xml b/study-shiro-spring-boot/pom.xml index ba91c4892..b3da965da 100644 --- a/study-shiro-spring-boot/pom.xml +++ b/study-shiro-spring-boot/pom.xml @@ -16,8 +16,8 @@ UTF-8 - 1.7 - 1.7 + 1.8 + 1.8 2.0.1.RELEASE 1.8 diff --git a/study-shiro-tutorial/pom.xml b/study-shiro-tutorial/pom.xml index 66cd5834a..51597502f 100644 --- a/study-shiro-tutorial/pom.xml +++ b/study-shiro-tutorial/pom.xml @@ -12,6 +12,8 @@ http://maven.apache.org UTF-8 + 1.8 + 1.8 diff --git a/study-shiro-web-tutorial/pom.xml b/study-shiro-web-tutorial/pom.xml index 79fdc34ab..829bff6cf 100644 --- a/study-shiro-web-tutorial/pom.xml +++ b/study-shiro-web-tutorial/pom.xml @@ -14,6 +14,8 @@ 1.3.2 UTF-8 + 1.8 + 1.8 4.3.9.RELEASE 3.1.0 2.3.4 diff --git a/study-shiro-web/pom.xml b/study-shiro-web/pom.xml index 266c6567d..8cce15c44 100644 --- a/study-shiro-web/pom.xml +++ b/study-shiro-web/pom.xml @@ -16,6 +16,8 @@ 1.3.2 UTF-8 + 1.8 + 1.8 4.3.9.RELEASE 3.1.0 2.3.4 diff --git a/study-socket/pom.xml b/study-socket/pom.xml index 98308e6dc..4de5fb7ef 100644 --- a/study-socket/pom.xml +++ b/study-socket/pom.xml @@ -14,6 +14,8 @@ http://maven.apache.org UTF-8 + 1.8 + 1.8 diff --git a/study-split-db-tb/pom.xml b/study-split-db-tb/pom.xml index 733faf509..bd31aa5de 100644 --- a/study-split-db-tb/pom.xml +++ b/study-split-db-tb/pom.xml @@ -156,7 +156,7 @@ org.projectlombok lombok - 1.16.18 + 1.18.20 provided diff --git a/study-spring-boot-actuator/pom.xml b/study-spring-boot-actuator/pom.xml index 62f303cb6..d129bdd76 100644 --- a/study-spring-boot-actuator/pom.xml +++ b/study-spring-boot-actuator/pom.xml @@ -17,6 +17,8 @@ UTF-8 + 1.8 + 1.8 2.1.7.RELEASE springio diff --git a/study-spring-boot-building/pom.xml b/study-spring-boot-building/pom.xml index c4187ea8d..9b6274156 100644 --- a/study-spring-boot-building/pom.xml +++ b/study-spring-boot-building/pom.xml @@ -17,6 +17,8 @@ UTF-8 + 1.8 + 1.8 2.0.1.RELEASE 1.8 diff --git a/study-spring-boot-dependencies/pom.xml b/study-spring-boot-dependencies/pom.xml index c90827882..972c9d519 100644 --- a/study-spring-boot-dependencies/pom.xml +++ b/study-spring-boot-dependencies/pom.xml @@ -14,6 +14,8 @@ UTF-8 + 1.8 + 1.8 2.0.1.RELEASE diff --git a/study-spring-boot-docker/pom.xml b/study-spring-boot-docker/pom.xml index 79529c8bd..26632bd69 100644 --- a/study-spring-boot-docker/pom.xml +++ b/study-spring-boot-docker/pom.xml @@ -18,6 +18,8 @@ UTF-8 + 1.8 + 1.8 2.0.1.RELEASE springio diff --git a/study-spring-boot-dynamic-datasource/pom.xml b/study-spring-boot-dynamic-datasource/pom.xml index ebc31aa28..6c069dfdd 100644 --- a/study-spring-boot-dynamic-datasource/pom.xml +++ b/study-spring-boot-dynamic-datasource/pom.xml @@ -16,6 +16,8 @@ UTF-8 + 1.8 + 1.8 2.0.1.RELEASE 3.4.6 diff --git a/study-spring-boot-elk/pom.xml b/study-spring-boot-elk/pom.xml new file mode 100644 index 000000000..1f8087af1 --- /dev/null +++ b/study-spring-boot-elk/pom.xml @@ -0,0 +1,84 @@ + + + + 4.0.0 + + com.bage + study-spring-boot-elk + 0.0.1-SNAPSHOT + + study-spring-boot-elk + + http://www.example.com + + + + UTF-8 + 1.8 + 1.8 + 2.0.1.RELEASE + springio + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter + + + org.springframework.boot + spring-boot-starter-log4j2 + + + org.springframework.boot + spring-boot-starter-test + + + + + net.logstash.logback + logstash-logback-encoder + 5.1 + + + + + + + + + + + + org.springframework.boot + spring-boot-dependencies + ${spring.boot.base.version} + pom + import + + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + + + diff --git a/study-spring-boot-elk/src/main/java/com/bage/ElkApplication.java b/study-spring-boot-elk/src/main/java/com/bage/ElkApplication.java new file mode 100644 index 000000000..36b145dc7 --- /dev/null +++ b/study-spring-boot-elk/src/main/java/com/bage/ElkApplication.java @@ -0,0 +1,55 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.bage; + + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.web.client.RestTemplate; + +import java.time.LocalDateTime; + +/** + * @author lrh + */ +@SpringBootApplication +public class ElkApplication implements CommandLineRunner { + + private static final Logger log = LoggerFactory.getLogger(ElkApplication.class); + + + public static void main(String[] args) { + SpringApplication.run(ElkApplication.class, args); + } + + @Bean + public RestTemplate restTemplate() { + return new RestTemplate(); + } + + @Override + public void run(String... args) throws Exception { + for (int i = 0; i < 1000; i++) { + Thread.sleep(3000L); + log.info("run: {}", LocalDateTime.now().toString()); + } + } +} \ No newline at end of file diff --git a/study-spring-boot-elk/src/main/resources/application.yml b/study-spring-boot-elk/src/main/resources/application.yml new file mode 100644 index 000000000..6cae837b9 --- /dev/null +++ b/study-spring-boot-elk/src/main/resources/application.yml @@ -0,0 +1,3 @@ +spring: + application: + name: hello-hhh diff --git a/study-spring-boot-elk/src/main/resources/logback.xml b/study-spring-boot-elk/src/main/resources/logback.xml new file mode 100644 index 000000000..4122587df --- /dev/null +++ b/study-spring-boot-elk/src/main/resources/logback.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + INFO + + + + ${CONSOLE_LOG_PATTERN} + utf8 + + + + + + 127.0.0.1:8044 + + + + + UTC + + + + { + "severity": "%level", + "appName":"${springAppName:-}", + "service": "${springAppName:-}", + "trace": "%X{X-B3-TraceId:-}", + "span": "%X{X-B3-SpanId:-}", + "exportable": "%X{X-Span-Export:-}", + "pid": "${PID:-}", + "thread": "%thread", + "class": "%logger{40}", + "rest": "%message" + } + + + + + + + + + + + + + \ No newline at end of file diff --git a/study-spring-boot-env/pom.xml b/study-spring-boot-env/pom.xml index b3361bf34..cdea27078 100644 --- a/study-spring-boot-env/pom.xml +++ b/study-spring-boot-env/pom.xml @@ -17,6 +17,8 @@ UTF-8 + 1.8 + 1.8 2.0.1.RELEASE diff --git a/study-spring-boot-jpa/pom.xml b/study-spring-boot-jpa/pom.xml index 5517cc8c3..385be6e5a 100644 --- a/study-spring-boot-jpa/pom.xml +++ b/study-spring-boot-jpa/pom.xml @@ -17,6 +17,8 @@ UTF-8 + 1.8 + 1.8 2.0.1.RELEASE diff --git a/study-spring-boot-metrics/pom.xml b/study-spring-boot-metrics/pom.xml index 8aaa3a1ce..cf59611c5 100644 --- a/study-spring-boot-metrics/pom.xml +++ b/study-spring-boot-metrics/pom.xml @@ -17,6 +17,8 @@ UTF-8 + 1.8 + 1.8 2.0.1.RELEASE diff --git a/study-spring-boot-multi-datasource/pom.xml b/study-spring-boot-multi-datasource/pom.xml index 355aaa4c8..0860bf90e 100644 --- a/study-spring-boot-multi-datasource/pom.xml +++ b/study-spring-boot-multi-datasource/pom.xml @@ -16,6 +16,8 @@ UTF-8 + 1.8 + 1.8 2.0.1.RELEASE 3.4.6 diff --git a/study-spring-boot-oauth2-auth-server/pom.xml b/study-spring-boot-oauth2-auth-server/pom.xml index 5b5a484cb..7084e0659 100644 --- a/study-spring-boot-oauth2-auth-server/pom.xml +++ b/study-spring-boot-oauth2-auth-server/pom.xml @@ -14,7 +14,7 @@ 1.8 1.8 - UTF-8 + 2.0.1.RELEASE diff --git a/study-spring-boot-sso-oauth2-server/readme-sso.md b/study-spring-boot-sso-oauth2-server/readme-sso.md new file mode 100644 index 000000000..c60e916fc --- /dev/null +++ b/study-spring-boot-sso-oauth2-server/readme-sso.md @@ -0,0 +1,384 @@ +# SSO # + + + +## 基本概念 ## + +### 什么是SSO ### +登陆 + +认证 + +授权 + +Single Sign On,单点登录,一次登录,处处【子系统】登录 + + + +### OAuth2.0相关概念 ### + +#### 四个职责划分 #### +- resource owner + + An entity capable of granting access to a protected resource. + When the resource owner is a person, it is referred to as an + end-user. + +- resource server + + The server hosting the protected resources, capable of accepting + and responding to protected resource requests using access tokens. + +- client + + An application making protected resource requests on behalf of the + resource owner and with its authorization. The term "client" does + not imply any particular implementation characteristics (e.g., + whether the application executes on a server, a desktop, or other + devices). + +- authorization server + + The server issuing access tokens to the client after successfully + authenticating the resource owner and obtaining authorization. + +#### 四种模式 #### +- 授权码模式 +老大,666,不会错 +- 密码模式 +传密码,不提倡 +- 简化模式 +不经过client的server端,用户透明,不建议 +- 客户端模式 +client + secret,不细化到用户,不会用 + +## 背景 ## +- 单体应用逐渐不能满足要求 +- 企业内部独立服务众多与统一账号管理存在矛盾 +- 集群以及多系统登录复杂性 + +## 实现方案 ## +### 自实现 ### +- 独立自主完成,全部自己实现一个单点登录 +### CAS ### +Central Authentication Service,耶鲁大学的统一鉴权服务 + +#### 优点 #### +- 开源,可定制化 +- Spring Webflow/Spring Boot Java server component +- 多种认证支持 (LDAP, Database, X.509, SPNEGO, JAAS, JWT, RADIUS, MongoDb, etc) +- 多种协议支持 (CAS, SAML, WS-Federation, OAuth2, OpenID, OpenID Connect, REST) +- 实时监控和跟踪应用程序行为,统计信息和日志。 +- 跨平台的客户端支持 (Java, .Net, PHP, Perl, Apache, etc) + +#### 不足 #### +- 基于cookie +- 客户端管理问题? + +#### 核心 #### +- CAS Server + TicketGrantingTicketCheckAction 校验ticket + AcceptUsersAuthenticationHandler 校验用户登录 +- CAS Clients + AuthenticationFilter 核心入口,校验登录 + 重定向等 + AbstractTicketValidationFilter(AuthenticationFilter调用) 校验ticket + CasHttpServletRequestWrapper + +#### 认证流程 #### +![Web flow diagram](https://apereo.github.io/cas/4.2.x/images/cas_flow_diagram.png) + +### Spring OAuth2.0 ### +Spring 的,基于 OAuth2.0 协议的, SSO实现方案 + +#### 优点 #### +- Spring 全家桶之一,与Spring配合默契,喜欢的样子它都有 +- 客户端统一管理 零成本 + +#### 不足 #### +- OAuth2.0 的Java 应用客户端 + +#### 核心 #### +- Spring Security + 实现 *AuthenticationProvider* 用户登录验证 + 实现 *UserDetailsService* 用户loadUserByUsername + 集成 *WebSecurityConfigurerAdapter* 装配 自定义用户登录验证 + URL Pattern +- Spring 集成 OAuth2.0 + *AuthorizationEndpoint* 认证登录 + *TokenEndpoint* 验证Token + *OAuth2AuthenticationProcessingFilter* is used to load the Authentication for the request given an authenticated access token. + + *ClientDetailsServiceConfigurer* 客户端信息配置 + *AuthorizationServerSecurityConfigurer*: defines the security constraints on the token endpoint. + *AuthorizationServerEndpointsConfigurer*: defines the authorization and token endpoints and the token services. + +#### 认证流程 #### +授权码模式 + + +--------+ +---------------+ + | |--(A)- Authorization Request ->| Resource | + | | | Owner | + | |<-(B)-- Authorization Grant ---| | + | | +---------------+ + | | + | | +---------------+ + | |--(C)-- Authorization Grant -->| Authorization | + | Client | | Server | + | |<-(D)----- Access Token -------| | + | | +---------------+ + | | + | | +---------------+ + | |--(E)----- Access Token ------>| Resource | + | | | Server | + | |<-(F)--- Protected Resource ---| | + +--------+ +---------------+ + + Figure 1: Abstract Protocol Flow + + 用户访问受保护资源,客户端验证用户登录状态,未登录,则进入步骤A + + (A) 客户端请求用户给予授权,页面跳转到登录页面,用户输入用户名、密码进行登录,登录成功后,则进入步骤B + + (B) 授权后,返回一个code + state(可选),进入步骤C + + (C) 客户端拿到授权码,凭借授权码code请求授权中心验证,进入步骤D + + (D) 若验证成功,则返回AccessToken.则进入步骤E + + (E) 客户端拿到AccessToken,带上,请求受保护资源. + + (F) 资源服务器验证token合法,则返回受保护的资源. + + + +### Spring OAuth2.0 SSO ### + +服务端-拦截规则 + +```java + @Override +protected void configure(HttpSecurity http) throws Exception { + http.authorizeRequests() + .antMatchers("/oauth/**","/login/**", "/logout").permitAll() + .anyRequest().authenticated() // 其他地址的访问均需验证权限 + .and() + .formLogin() + .loginPage("/login") + .and() + .logout().logoutSuccessUrl("/"); +} +``` +服务端-资源路径 + + @Override + public void configure(HttpSecurity http) throws Exception { + http.requestMatchers().antMatchers("/user/**") + .and() + .authorizeRequests() + .anyRequest().authenticated(); + } +服务端-客户端列表 + +```java +@Override +public void configure(ClientDetailsServiceConfigurer clients) throws Exception { + clients.jdbc(dataSource); + /* + clients.inMemory() + .withClient("sampleClientId") + .secret(passwordEncoder.encode("secret")) + .authorizedGrantTypes("authorization_code") + .scopes("user_info") + .autoApprove(true) + .redirectUris("http://localhost:8001/client1/login") + // .accessTokenValiditySeconds(3600) + ; // 1 hour +*/ +} +``` + +SQL + +```sql +INSERT INTO oauth_client_details + (client_id, client_secret, scope, authorized_grant_types, + web_server_redirect_uri, authorities, access_token_validity, + refresh_token_validity, additional_information, autoapprove) +VALUES + ('sampleClientId', '$2a$10$i7bPh8Npg8lsUTxOAwp7suAwMxTw8tNyRkvDJT8/uZGcSzdFocHS6', 'user_info', + 'password,authorization_code,refresh_token,client_credentials', 'http://localhost:8001/client1/login,http://localhost:8002/client2/login', null, 36000, 36000, null, true); +``` +客户端- application.yml + +```yml +server: + port: 8001 + servlet: + context-path: /client1 + +security: + oauth2: + client: + client-id: sampleClientId + client-secret: secret + access-token-uri: http://localhost:8080/oauth/token + user-authorization-uri: http://localhost:8080/oauth/authorize + resource: + user-info-uri: http://localhost:8080/user/me +``` + 客户端-拦截规则 + +```java +@EnableOAuth2Sso +@Configuration +@EnableGlobalMethodSecurity(prePostEnabled = true) +public class ClientSecurityConfig extends WebSecurityConfigurerAdapter { + @Override + public void configure(HttpSecurity http) throws Exception { + http.antMatcher("/**") + .authorizeRequests() + .antMatchers("/", "/login**", "/webjars/**", "/error**").permitAll() + .anyRequest() + .authenticated() + .and().logout().logoutSuccessUrl("/") + .and().csrf() + .csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse()); + ; + } +} +``` +完整代码 + + +- Auth Server [https://github.com/bage2014/study/tree/master/study-spring-boot-sso-oauth2-server](https://github.com/bage2014/study/tree/master/study-spring-boot-sso-oauth2-server) +- Client [https://github.com/bage2014/study/tree/master/study-spring-boot-sso-oauth2-client1](https://github.com/bage2014/study/tree/master/study-spring-boot-sso-oauth2-client1) + +Ctrip SSO [http://git.ctripcorp.com/global-rail-gds/gds-admin-application](http://git.ctripcorp.com/global-rail-gds/gds-admin-application) + +### JWT ### +核心实现 + +1. 登录过程 + + public String login(HttpServletRequest request){ + + String account = request.getParameter("account"); + Map map = new HashMap(); + map.put("account", account); + map.put("password", request.getParameter("password")); + map = userService.query(map); + + if(map != null ) { //登录成功 + + Key key = MacProvider.generateKey(); + Map cliams = new HashMap(); + cliams.put("jti", String.valueOf(System.currentTimeMillis())); + String jws = Jwts.builder() + .setClaims(cliams ) + .setIssuer("com.bage") // iss: 该JWT的签发者,是否使用是可选的 + .setSubject(account) // sub: 该JWT所面向的用户,是否使用是可选的; + //.setAudience(aud) // aud: 接收该JWT的一方,是否使用是可选的 + .setExpiration(DateUtils.getJwtsExpirationDate()) // exp(expires): 什么时候过期,这里是一个Unix时间戳,是否使用是可选的 + .setIssuedAt(DateUtils.now()) // iat(issued at): 在什么时候签发的(UNIX时间),是否使用是可选的 + //.setNotBefore(DateUtils.getNotBeforeDate()) // nbf (Not Before):如果当前时间在nbf里的时间之前,则Token不被接受;一般都会留一些余地,比如几分钟;是否使用是可选的 + .signWith(SignatureAlgorithm.HS512, key) + .compact(); + + System.out.println("jws:" + jws); + + RedisUtils.put(Constants.redis_key_jwt + "_" + account, jws); + RedisUtils.put(Constants.redis_key_jwtkey + "_" + account, key); + + map = new HashMap(); + map.put("jws", jws); + map.put("now", DateUtils.now()); + map.put("expirationDate", DateUtils.getJwtsExpirationDate()); + + return JsonUtils.toJson(map); + + } else { // 登录失败 + return ""; + } + } +2. 校验逻辑 + +```java +if(!isExcludeUri(request)) { + String claimsJws = request.getHeader("Authorization"); + System.out.println("参数compactJws:" + claimsJws); + // 签名验证 + try { + Claims claims = JwtsBuilder.decodeTokenClaims(claimsJws); + String subject = claims.getSubject(); + Key key = (Key) RedisUtils.get(Constants.redis_key_jwt + "_" + subject); + Jws jws = Jwts.parser().setSigningKey(key).parseClaimsJws(claimsJws); + System.out.println("jti:" + jws.getBody().get("jti")); + String currentCompactJws = RedisUtils.getString(Constants.redis_key_jwt + "_" + subject); + if(currentCompactJws == null || !currentCompactJws.equals(claimsJws)) { + System.out.println("签名不合法:\ncompactJws:" + claimsJws); + System.out.println("currentCompactJws:" + currentCompactJws); + checkJwtFail(request, response); + return ; + } + } catch (Exception e) { + e.printStackTrace(); + System.out.println("解析签名报错"); + checkJwtFail(request, response); + return ; + } + } + + chain.doFilter(request, response); +``` + +3. 区分请求类型 + +```java +private void checkJwtFail(HttpServletRequest request,HttpServletResponse response) { + try { + String requestType = request.getHeader("X-Requested-With"); + if("XMLHttpRequest".equals(requestType)){ // TODO 增加跨域请求校验 + System.out.println("AJAX请求.."); + response.getWriter().print("Authorization Failed"); + }else{ + System.out.println("非AJAX请求.."); + response.sendRedirect(request.getServletContext().getContextPath() + "/"); + //此时requestType为null + } + //request.getSession().removeAttribute(Constants.session_attribute_currentuser); + } catch (IOException e) { + e.printStackTrace(); + } +} +``` + +完整代码 + +单体应用 [https://github.com/bage2014/study/tree/master/study-jwt](https://github.com/bage2014/study/tree/master/study-jwt) + +## 总结 ## + +### SSO的本质 ### +- 共享登录信息(共用Session || JWT) +- 认证中心 + 客户端模式 + +### oauth2.0 与 SSO 的关系 ### +- Oauth2.0 是 一种协议,SSO是 一个功能 +- SSO可以基于 OAuth 2.0协议实现 +- Oauth2.0可以用于其他功能,比如资源授权 +### SSO实现方案的抉择 ### +- 合适的就是最好的 +- 企业之间 || Restful,推荐 Spring OAuth2.0 +### Spring OAuth2.0 JWT ### +- Session 弱化场景 +- 防重放 +- JWT失效时间控制 + +## 参考链接 ## +- 单点登录 CAS 官网 [https://www.apereo.org/projects/cas](https://www.apereo.org/projects/cas) +- cas 文档 [https://apereo.github.io/cas/4.2.x/index.html](https://apereo.github.io/cas/4.2.x/index.html) +- cas github地址 [https://github.com/apereo/cas](https://github.com/apereo/cas) +- CAS 登录过程源码解析 [https://segmentfault.com/a/1190000014001205?utm_source=channel-hottest](https://segmentfault.com/a/1190000014001205?utm_source=channel-hottest) +- Oauth2.0协议 [http://www.rfcreader.com/#rfc6749](http://www.rfcreader.com/#rfc6749) +- 阮一峰 理解OAuth 2.0 [http://www.ruanyifeng.com/blog/2014/05/oauth_2_0.html](http://www.ruanyifeng.com/blog/2014/05/oauth_2_0.html) +- Spring OAuth 2.0 官网 [https://projects.spring.io/spring-security-oauth/docs/oauth2.html](https://projects.spring.io/spring-security-oauth/docs/oauth2.html) +- 携程单点登录接入Conf [http://conf.ctripcorp.com/pages/viewpage.action?pageId=157466083](http://conf.ctripcorp.com/pages/viewpage.action?pageId=157466083)、[http://conf.ctripcorp.com/pages/viewpage.action?pageId=135658955](http://conf.ctripcorp.com/pages/viewpage.action?pageId=135658955) diff --git a/study-spring-boot-websocket/pom.xml b/study-spring-boot-websocket/pom.xml index b77cc7004..85da5997f 100644 --- a/study-spring-boot-websocket/pom.xml +++ b/study-spring-boot-websocket/pom.xml @@ -17,8 +17,8 @@ UTF-8 - 1.7 - 1.7 + 1.8 + 1.8 diff --git a/study-spring-boot-zipkin/pom.xml b/study-spring-boot-zipkin/pom.xml index 523d281ff..f657e1e6d 100644 --- a/study-spring-boot-zipkin/pom.xml +++ b/study-spring-boot-zipkin/pom.xml @@ -17,6 +17,8 @@ UTF-8 + 1.8 + 1.8 2.0.1.RELEASE diff --git a/study-spring-boot/pom.xml b/study-spring-boot/pom.xml index 0beb926a9..ab27c416a 100644 --- a/study-spring-boot/pom.xml +++ b/study-spring-boot/pom.xml @@ -15,6 +15,8 @@ UTF-8 + 1.8 + 1.8 2.0.1.RELEASE diff --git a/study-spring-dependencies/pom.xml b/study-spring-dependencies/pom.xml index 857cb5926..f9b49d424 100644 --- a/study-spring-dependencies/pom.xml +++ b/study-spring-dependencies/pom.xml @@ -13,6 +13,8 @@ UTF-8 + 1.8 + 1.8 4.3.9.RELEASE UTF-8 3.0-alpha-1 diff --git a/study-spring-email/pom.xml b/study-spring-email/pom.xml index 6d84230b0..ae0311544 100644 --- a/study-spring-email/pom.xml +++ b/study-spring-email/pom.xml @@ -16,6 +16,8 @@ http://www.example.com UTF-8 + 1.8 + 1.8 2.0.1.RELEASE diff --git a/study-spring-session/pom.xml b/study-spring-session/pom.xml index 53ff8f9ef..0b9e47c5b 100644 --- a/study-spring-session/pom.xml +++ b/study-spring-session/pom.xml @@ -15,6 +15,8 @@ UTF-8 + 1.8 + 1.8 5.0.9.RELEASE UTF-8 3.0-alpha-1 diff --git a/study-spring/pom.xml b/study-spring/pom.xml index b77ab24b7..077db7040 100644 --- a/study-spring/pom.xml +++ b/study-spring/pom.xml @@ -13,6 +13,8 @@ http://maven.apache.org UTF-8 + 1.8 + 1.8 4.3.9.RELEASE UTF-8 3.0-alpha-1 diff --git a/study-springmvc-java/pom.xml b/study-springmvc-java/pom.xml index 94a3af8e9..fd0d48e0c 100644 --- a/study-springmvc-java/pom.xml +++ b/study-springmvc-java/pom.xml @@ -14,6 +14,8 @@ UTF-8 + 1.8 + 1.8 4.3.9.RELEASE UTF-8 3.0-alpha-1 diff --git a/study-springmvc-xml/pom.xml b/study-springmvc-xml/pom.xml index c6b62aabb..36c97ee5b 100644 --- a/study-springmvc-xml/pom.xml +++ b/study-springmvc-xml/pom.xml @@ -14,7 +14,7 @@ UTF-8 - 4.3.9.RELEASE + 5.2.22.RELEASE UTF-8 3.0-alpha-1 2.1 diff --git a/study-sql/pom.xml b/study-sql/pom.xml index 6a8654523..322f11bfe 100644 --- a/study-sql/pom.xml +++ b/study-sql/pom.xml @@ -24,6 +24,8 @@ http://maven.apache.org UTF-8 + 1.8 + 1.8 diff --git a/study-sql/src/main/resources/init.sql b/study-sql/src/main/resources/init.sql new file mode 100644 index 000000000..9eb068cd3 --- /dev/null +++ b/study-sql/src/main/resources/init.sql @@ -0,0 +1,9 @@ + +-- index +alter table sl_test add key idx_first_name(first_name); +show indexes from sl_test; + +-- init data +insert sl_test(id,sex,birth,age,first_name,last_name) values (1,'男','2022-01-01 00:00:00',1,'bage','lu'); +insert sl_test(id,sex,birth,age,first_name,last_name) values (2,'女','2020-01-01 00:00:00',3,'bage3','lu'); + diff --git a/study-sql/src/main/resources/schema.sql b/study-sql/src/main/resources/schema.sql new file mode 100644 index 000000000..c88f3a30a --- /dev/null +++ b/study-sql/src/main/resources/schema.sql @@ -0,0 +1,10 @@ + +CREATE TABLE sl_test( +id SERIAL, +sex varchar(64), +birth date, +age int, +first_name VARCHAR(64), +last_name VARCHAR(64) +); + diff --git a/study-sso-baeldung-auth-server/pom.xml b/study-sso-baeldung-auth-server/pom.xml index a51c9e21c..01d0110a9 100644 --- a/study-sso-baeldung-auth-server/pom.xml +++ b/study-sso-baeldung-auth-server/pom.xml @@ -13,6 +13,8 @@ UTF-8 + 1.8 + 1.8 1.5.10.RELEASE diff --git a/study-sso-baeldung-client1/pom.xml b/study-sso-baeldung-client1/pom.xml index b03aece75..173d2f108 100644 --- a/study-sso-baeldung-client1/pom.xml +++ b/study-sso-baeldung-client1/pom.xml @@ -14,6 +14,8 @@ UTF-8 + 1.8 + 1.8 1.5.10.RELEASE diff --git a/PPT.md b/study-summary/PPT.md similarity index 100% rename from PPT.md rename to study-summary/PPT.md diff --git a/README-OS-Reinstall.md b/study-summary/README-OS-Reinstall.md similarity index 100% rename from README-OS-Reinstall.md rename to study-summary/README-OS-Reinstall.md diff --git a/README-WeChat-Developer.md b/study-summary/README-WeChat-Developer.md similarity index 100% rename from README-WeChat-Developer.md rename to study-summary/README-WeChat-Developer.md diff --git a/study-summary/README-bilibili.md b/study-summary/README-bilibili.md new file mode 100644 index 000000000..e38b02462 --- /dev/null +++ b/study-summary/README-bilibili.md @@ -0,0 +1,305 @@ +# 进度备忘 + + + +面试汇总: + +Spring Cloud: + +http://c.biancheng.net/springcloud/eureka.html + +http://c.biancheng.net/springcloud/ + +https://blog.csdn.net/yanpenglei/article/details/121994645 + +https://blog.csdn.net/m0_48795607/article/details/115917190 + + + +MySQL + +https://www.cnblogs.com/setalone/p/14851000.html + +索引下推:https://baijiahao.baidu.com/s?id=1716515482593299829&wfr=spider&for=pc + +DB Log : + +https://www.baidu.com/baidu?tn=monline_7_dg&ie=utf-8&wd=%E6%95%B0%E6%8D%AE%E5%BA%93%E6%97%A5%E5%BF%97 + + + +Tomcat + +https://baijiahao.baidu.com/s?id=1707755764671407613&wfr=spider&for=pc + +http://www.javashuo.com/article/p-feodoefp-md.html + +https://blog.csdn.net/zps66/article/details/117673727 + +https://server.it168.com/a2017/0901/3168/000003168567.shtml + + + +场景设计: + +https://github.com/Snailclimb/JavaGuide-Interview/blob/master/docs/f-2%E7%B3%BB%E7%BB%9F%E8%AE%BE%E8%AE%A1%E9%9D%A2%E8%AF%95%E6%8C%87%E5%8C%97.md + + + +Kafaka: + +https://github.com/Snailclimb/JavaGuide-Interview/blob/master/docs/e-3kafka.md + +https://blog.csdn.net/yanpenglei/article/details/121862772 + +https://zhuanlan.zhihu.com/p/469002514 + + + +https://github.com/Snailclimb/JavaGuide + +https://hadyang.com/interview/docs/architecture/distributed/dubbo/ + +https://github.com/yuanguangxin/LeetCode + +https://github.com/gzc426/Java-Interview/tree/master/docs + +https://github.com/Snailclimb/JavaGuide-Interview/tree/master/docs + +https://github.com/itdevbooks/tech + + + +当前进度:11 + +https://zhuanlan.zhihu.com/p/64147696 + + + +Spring + +https://www.bilibili.com/video/BV1y541127Yg?spm_id_from=333.851.b_7265636f6d6d656e64.6 + + + +压测JMetter + +https://www.bilibili.com/video/BV1st411Y7QW?spm_id_from=333.337.search-card.all.click + +https://www.bilibili.com/video/BV1hL4y1B7Et?spm_id_from=333.337.search-card.all.click + + + +https://leetcode-cn.com/problems/UHnkqh/ + +问答 + +https://www.bilibili.com/video/BV1iV411p7LU?p=134 + +问答 + +https://www.bilibili.com/video/BV1iV411p7LU?p=39 + +https://www.bilibili.com/video/BV1iV411p7LU?p=38 + +https://www.bilibili.com/video/BV1iV411p7LU?p=36 + +https://www.bilibili.com/video/BV1iV411p7LU?p=35 + +https://www.bilibili.com/video/BV1iV411p7LU?p=34&spm_id_from=pageDriver + +https://www.bilibili.com/video/BV1iV411p7LU?p=33 + +https://www.bilibili.com/video/BV1iV411p7LU?p=32 + +https://www.bilibili.com/video/BV1iV411p7LU?p=31 + +https://www.bilibili.com/video/BV1iV411p7LU?p=30&spm_id_from=pageDriver + +https://www.bilibili.com/video/BV1iV411p7LU?p=24&spm_id_from=pageDriver + +https://www.bilibili.com/video/BV1iV411p7LU?p=9&spm_id_from=pageDriver + +https://www.bilibili.com/video/BV1iV411p7LU?from=search&seid=7880316255452534004&spm_id_from=333.337.0.0 + +注册中心、分布式事务、网管 + +ShardingSphere + +https://www.bilibili.com/video/BV1XU4y177De?from=search&seid=5629134683248808430&spm_id_from=333.337.0.0 + +https://www.bilibili.com/video/BV1uz4y1S7ov?p=2 + +Spring Boot + +https://www.bilibili.com/video/BV1nK4y1H7g9?p=189 + +https://www.bilibili.com/video/BV1nK4y1H7g9?p=186 + +https://www.bilibili.com/video/BV1nK4y1H7g9?p=185 + +https://www.bilibili.com/video/BV1nK4y1H7g9?p=184 + +Spring Cloud + +https://www.bilibili.com/video/BV1nK4y1H7g9?p=182 + +https://www.bilibili.com/video/BV1nK4y1H7g9?p=178&spm_id_from=pageDriver + +https://www.bilibili.com/video/BV1nK4y1H7g9?p=175 + +https://www.bilibili.com/video/BV1nK4y1H7g9?p=174&spm_id_from=pageDriver + +https://www.bilibili.com/video/BV1nK4y1H7g9?p=173&spm_id_from=pageDriver + +https://www.bilibili.com/video/BV1nK4y1H7g9?p=170&spm_id_from=pageDriver + +Spring Cloud Nacoss + +https://www.bilibili.com/video/BV1nK4y1H7g9?p=167&spm_id_from=pageDriver + +https://www.bilibili.com/video/BV1nK4y1H7g9?p=165 + + + +dubbo【暂时段落】 + +https://www.bilibili.com/video/BV1nK4y1H7g9?p=142&spm_id_from=pageDriver + +https://www.bilibili.com/video/BV1nK4y1H7g9?p=140&spm_id_from=pageDriver + +https://www.bilibili.com/video/BV1nK4y1H7g9?p=138&spm_id_from=pageDriver + +https://www.bilibili.com/video/BV1nK4y1H7g9?p=137&spm_id_from=pageDriver + +https://www.bilibili.com/video/BV1nK4y1H7g9?p=134 + + + +Tomcat + +https://www.bilibili.com/video/BV1nK4y1H7g9?p=27&spm_id_from=pageDriver + +https://www.bilibili.com/video/BV1nK4y1H7g9?p=25&spm_id_from=pageDriver + +https://www.bilibili.com/video/BV1nK4y1H7g9?p=24&spm_id_from=pageDriver + +https://www.bilibili.com/video/BV1nK4y1H7g9?p=20 + +JVM + +https://www.bilibili.com/video/BV1r3411Y7fd?spm_id_from=333.851.b_7265636f6d6d656e64.4 + + + + + +分布式ID + +https://www.bilibili.com/video/BV1nK4y1H7g9?p=154 + +分布式事务【未完成】 + +https://www.bilibili.com/video/BV1nK4y1H7g9?p=148 + + + +Spring MVC + +https://www.bilibili.com/video/BV1nK4y1H7g9?p=91&spm_id_from=pageDriver + +https://www.bilibili.com/video/BV1nK4y1H7g9?p=90&spm_id_from=pageDriver + +https://www.bilibili.com/video/BV1nK4y1H7g9?p=89 + +Spring AoP + +https://www.bilibili.com/video/BV1nK4y1H7g9?p=77&spm_id_from=pageDriver + +https://www.bilibili.com/video/BV1nK4y1H7g9?p=74 + +Spring 生命周期 +https://www.bilibili.com/video/BV1nK4y1H7g9?p=69&spm_id_from=pageDriver + +https://www.bilibili.com/video/BV1nK4y1H7g9?p=50 + +线程池 +https://www.bilibili.com/video/BV1nK4y1H7g9?p=58 + +Spring 手写 +https://www.bilibili.com/video/BV1nK4y1H7g9?p=68&spm_id_from=pageDriver + +常用点 +https://www.bilibili.com/video/BV1V44y1i7L8?p=2 + + +## 总结 +MySQL +1、 索引、联合索引 +2、 log日志 +3、 版本控制 +4、 + +Java 锁 +自旋锁 》 偏向锁 》 重量锁 + +Java 线程池 +优化?? +注意事项 + +条件短点 + + +# 常用链接 + + + +- 搜索结果 + +https://search.bilibili.com/all?keyword=JAVA%E9%9D%A2%E8%AF%95%E9%A2%982021&from_source=webtop_search&spm_id_from=333.851&order=totalrank&duration=4&tids_1=0 + + + + + +# [活动作品](https://www.bilibili.com/blackboard/techhunters3.html)2022年最新版Java面试题突击视频教程,不管工作几年还是应届生必看的Java面试必考真题【最强Java面试宝典】赶紧收藏起来! + + + +https://www.bilibili.com/video/BV1UU4y1u7fB?p=2&spm_id_from=pageDriver + + + +- 面试系列!! + +# Alibaba最新Java面试137题汇总详解__对标P7,全学完随便拿50Koffer + +https://www.bilibili.com/video/BV1V44y1i7L8?from=search&seid=16808638854944282623&spm_id_from=333.337.0.0 + + + +# [活动作品](https://www.bilibili.com/video/BV1aV411W7U2?from=search&seid=7880316255452534004&spm_id_from=333.337.0.0)B站最全面Java面试500讲(涵盖所有Java核心面试知识点),立刻收藏! + +https://www.bilibili.com/video/BV1aV411W7U2?from=search&seid=7880316255452534004&spm_id_from=333.337.0.0 + + + +- 马士兵 + +# 终于把阿里1350道Java面试题都讲明白了:开源视频+笔记+源码+文档+解析图 + +https://www.bilibili.com/video/BV1G44y1v7Hz?p=1 + + + +- 面试题目汇总-- + +https://www.bilibili.com/video/BV1iV411p7LU?from=search&seid=7880316255452534004&spm_id_from=333.337.0.0 + + + +https://www.bilibili.com/video/BV1w341187cF?from=search&seid=7880316255452534004&spm_id_from=333.337.0.0 + + + +https://www.bilibili.com/video/BV1444y1x7gJ?from=search&seid=591244058940940941&spm_id_from=333.337.0.0 diff --git a/study-summary/README-mq.md b/study-summary/README-mq.md new file mode 100644 index 000000000..00c6382b5 --- /dev/null +++ b/study-summary/README-mq.md @@ -0,0 +1,6 @@ +# Study-mq # + + +Kafaka: + +参考链接: https://blog.csdn.net/u012588879/article/details/122957237 \ No newline at end of file diff --git a/README-paxos.md b/study-summary/README-paxos.md similarity index 100% rename from README-paxos.md rename to study-summary/README-paxos.md diff --git a/study-summary/README-structure.md b/study-summary/README-structure.md new file mode 100644 index 000000000..63e213aa1 --- /dev/null +++ b/study-summary/README-structure.md @@ -0,0 +1,16 @@ +# 系统结构 + +技术要素 + +团队建设 + +发展 + +技术趋势 + +招兵买马 + + + + + diff --git a/study-summary/README.md b/study-summary/README.md index 94c481bff..9715805b9 100644 --- a/study-summary/README.md +++ b/study-summary/README.md @@ -2,6 +2,40 @@ PPT 讲解 STAR 法则,背景、遇到问题、采取的方案、取得的效果 +NEW STRAT +UT 编写用例 +管理学知识 +技术技能 +Cauch 教练管理方式 +裸心会 +调查问卷 + +代理: https://blog.csdn.net/lx1315998513/article/details/120641124 + + + +## 员工找回 + +Spring Security ,干掉profile 目录等 + +Spring Security 使用自定义 数据库表结构 + + + +## Mac 使用技巧 +https://zhuanlan.zhihu.com/p/89987302 + + + +查看端口占用: + +lsof -i:1234 + + + +58826 + + ## 常用连接 @@ -29,7 +63,7 @@ https://github.com/akullpp/awesome-java https://github.com/AobingJava/JavaFamily - +https://github.com/tuteng/Best-websites-a-programmer-should-visit-zh#interview-preparation ## [Java 基础](https://github.com/bage2014/interview/blob/master/README-Java.md) ## @@ -66,6 +100,10 @@ JDK各个版本特性; 数据库索引; +数据库读取,按页读取 + +各种索引对比 + 索引结构原理; innerDB等; @@ -142,6 +180,28 @@ CompletableFuture; ## [JVM](https://github.com/bage2014/interview/blob/master/README-Jvm.md) ## 常用理论知识,前世今生,开源组件; +### 对象创建 + +**常量池校验** + +**内存分配** + +1. 指针碰撞 +2. 空闲列表 + +内存分配线程安全 + +1. CAS线程枷锁实现 +2. TLAB 本地线程分配缓冲 + +**零值初始化** + +**对象元信息初始化** + +**Java 线程初始化** + + + ### 内存划分 ### 了解目标:基本概念、主要特点、常见异常 diff --git a/study-summary/pom.xml b/study-summary/pom.xml index 1fd030073..68c0c1d52 100644 --- a/study-summary/pom.xml +++ b/study-summary/pom.xml @@ -17,8 +17,8 @@ UTF-8 - 1.7 - 1.7 + 1.8 + 1.8 diff --git a/study-tencent-share/pom.xml b/study-tencent-share/pom.xml index bb611f51f..6aad43743 100644 --- a/study-tencent-share/pom.xml +++ b/study-tencent-share/pom.xml @@ -17,8 +17,8 @@ UTF-8 - 1.7 - 1.7 + 1.8 + 1.8 diff --git a/study-test-restdoc/pom.xml b/study-test-restdoc/pom.xml index 3ef952e51..68edfe7ca 100644 --- a/study-test-restdoc/pom.xml +++ b/study-test-restdoc/pom.xml @@ -17,6 +17,8 @@ UTF-8 + 1.8 + 1.8 2.0.1.RELEASE diff --git a/study-test/pom.xml b/study-test/pom.xml index ba0f604dd..8539d9a1c 100644 --- a/study-test/pom.xml +++ b/study-test/pom.xml @@ -12,6 +12,8 @@ http://maven.apache.org UTF-8 + 1.8 + 1.8 diff --git a/study-todo/README.md b/study-todo/README.md index 4a723193e..b367d614a 100644 --- a/study-todo/README.md +++ b/study-todo/README.md @@ -1,9 +1,299 @@ # study-TODO # 代办事项: +Kayak +PacificA : kafka采用的一致性协议 +压测 + + + +线上问题定位 + + + +Spring Cloud Alibaba 相关环境搭建 + +Docker 版本 + + + +API 方法 VS Logic 直接调用 + +Message Bus 抽取发送邮件方法 + + + +Auth Server 设置自定义User ID字段 + + + +yarn 配置淘宝 链接 + + + +vue 选型 + +目前采用: element plus + +https://element-plus.gitee.io/zh-CN/guide/design.html + + + +vue 使用route + +https://cn.vuejs.org/v2/guide/routing.html + +https://router.vuejs.org/zh/guide/#javascript + +https://github.com/chrisvfritz/vue-2.0-simple-routing-example/ + + + +统一校验登陆状态; + +后端,,, + +文件上传-待自测 + +、消息服务 ,进行实现 + +spring boot 日子打到ELK - done + + + + + + + +### docker 安装ELK + +#### 设置国内镜像 + +参考链接: https://www.csdn.net/tags/NtzaMgzsNDA4Ni1ibG9n.html + +**操作步骤** + +Docker Desktop 应用图标 -> Perferences,在左侧导航菜单选择 Docker Engine,在右侧像下边一样编辑 json 文件。修改完成之后,点击 Apply & Restart 按钮,Docker 就会重启并应用配置的镜像地址了。 + +```json +{ + "registry-mirrors": [ + "https://9cpn8tt6.mirror.aliyuncs.com", + "https://hub-mirror.c.163.com", + "https://registry.docker-cn.com" + ] +} +``` + +验证 + +``` +docker info +``` + +## + +### 安装ES + +Docker Pull Command + +``` +docker pull elasticsearch:7.16.2 + +``` + +创建基础目录 + +``` +mkdir /Users/bage/bage/docker-data/es + +bage % pwd +/Users/bage/bage/docker-data/es + +bage % ls +config data nodes plugins +``` + +编辑文件 + +``` +vi /Users/bage/bage/docker-data/es/config/elasticearch.yml + + +``` + +启动 + +``` +docker run --network myapp --name bage-es -p 9092:9200 -p 8093:9300 \ +-e "discovery.type=single-node" \ +-v /Users/bage/bage/docker-data/es/config/elasticearch.yml:/usr/share/elasticsearch/config/elasticearch.yml \ +-v /Users/bage/bage/docker-data/es/data:/usr/share/elasticsearch/data \ +-v /Users/bage/bage/docker-data/es/plugins:/usr/share/elasticsearch/plugins \ +-d elasticsearch:7.16.2 + +``` + + 访问 + +``` +http://127.0.0.1:9092/_cat/health +http://127.0.0.1:9092 + +查看索引 +http://localhost:9092/_cat/indices?v&pretty +``` + + + +### 安装kibana + +Docker Pull Command + +``` +docker pull kibana:7.16.2 + +``` + +创建基础目录 + +``` +mkdir /Users/bage/bage/docker-data/kibana + +bage % pwd +/Users/bage/bage/docker-data/kibana + +bage % ls +config +``` + +编辑文件[暂时不使用] + +``` +/Users/bage/bage/docker-data/kibana/config/kibana.yml + +server.port: 8056 +server.host: "0.0.0.0" +elasticsearch.url: "http://bage-es:9092" + +``` + +start a instance + +``` +docker run --network myapp -d --link bage-es:elasticsearch -p 9056:5601 --name bage-kibana \ +-d kibana:7.16.2 + +``` + +visit + +``` +http://127.0.0.1:9056/app/kibana + +http://127.0.0.1:9056/app/kibana#/dev_tools/console +``` + +**kibana里建立索引** + +通过kiban菜单去建立索引:Management>Index patterns>Create index pattern,这里会显示可用的索引名称。 + +可以直接搜索 index 找到 Create index pattern + + + +选择对应的索引 + + + +Discover 里面创建 看板 + +### 安装 logstash + +参考链接 https://www.elastic.co/guide/en/logstash/7.17/docker.html + +https://github.com/elastic/logstash/blob/7.17/config/logstash.yml + +Docker Pull Command + +``` +docker pull logstash:7.16.2 +``` + +创建基础目录 + +``` +mkdir /Users/bage/bage/docker-data/logstash + +bage % pwd +/Users/bage/bage/docker-data/logstash + +bage % ls +pipeline config + +``` + +编辑文件 + +``` +vi /Users/bage/bage/docker-data/logstash/config/logstash.yml + +http.host: "0.0.0.0" +# xpack.monitoring.elasticsearch.hosts: ["http://bage-es:9092"] +monitoring.elasticsearch.hosts: ["http://bage-es:9092"] +# path.config: /usr/share/logstash/config/conf.d/*.conf +# path.logs: /usr/share/logstash/logs + +``` + + + +``` +vi /Users/bage/bage/docker-data/logstash/pipeline/logstash.conf + +# Sample Logstash configuration for creating a simple +# Beats -> Logstash -> Elasticsearch pipeline. + +input { + tcp { + mode => "server" + port => 5044 + codec => json_lines + stat_interval => "5" + } +} + +output { + elasticsearch { + hosts => ["http://bage-es:9200"] + index => "{{indexName}}" + #user => "elastic" + #password => "changeme" + } +} + +``` + +start a instance + +``` +docker run --network myapp --name=bage-logstash \ +-p 8056:5601 \ +-p 8044:5044 \ +-v /Users/bage/bage/docker-data/logstash/config/logstash.yml:/usr/share/logstash/config/logstash.yml \ +-v /Users/bage/bage/docker-data/logstash/pipeline/:/usr/share/logstash/pipeline/ \ +-d logstash:7.16.2 + + +docker run --name bage-logstash --network myapp -p 8056:5601 --link bage-es:elasticsearch -d logstash:7.16.2 + +``` + +### 访问 + diff --git a/study-tomcat/README.md b/study-tomcat/README.md new file mode 100644 index 000000000..9d8aa1e78 --- /dev/null +++ b/study-tomcat/README.md @@ -0,0 +1,181 @@ +# study-Tomcat # +## ***性能优化*** + +参考链接: + +https://www.cnblogs.com/zhuawang/p/5213192.html + +***\*一:Tomcat内存优化,启动时告诉JVM我要一块大内存(调优内存是最直接的方式)\**** + +Windows 下的catalina.bat + +Linux 下的catalina.sh 如: + +JAVA_OPTS='-Xms256m -Xmx512m' + +-Xms JVM初始化堆的大小 + +-Xmx JVM堆的最大值 实际参数大小根据服务器配置或者项目具体设置. + +***\*二:Tomcat 线程优化\**** 在server.xml中 如: + + + +maxThreads="X" 表示最多同时处理X个连接 + +minSpareThreads="X" 初始化X个连接 + +maxSpareThreads="X" 表示如果最多可以有X个线程,一旦超过X个,则会关闭不在需要的线程 + +acceptCount="X" 当同时连接的人数达到maxThreads时,还可以排队,队列大小为X.超过X就不处理 + +***\*三:Tomcat IO优化\**** + +1:同步阻塞IO(JAVA BIO) 同步并阻塞,服务器实现模式为一个连接一个线程(one connection one thread 想想都觉得恐怖,线程可是非常宝贵的资源),当然可以通过线程池机制改善. + +2:JAVA NIO:又分为同步非阻塞IO,异步阻塞IO 与BIO最大的区别one request one thread.可以复用同一个线程处理多个connection(多路复用). + +3:,异步非阻塞IO(Java NIO2又叫AIO) 主要与NIO的区别主要是操作系统的底层区别.可以做个比喻:比作快递,NIO就是网购后要自己到官网查下快递是否已经到了(可能是多次),然后自己去取快递;AIO就是快递员送货上门了(不用关注快递进度)。 + +BIO方式适用于连接数目比较小且固定的架构,这种方式对服务器资源要求比较高,并发局限于应用中,JDK1.4以前的唯一选择,但程序直观简单易理解. + +NIO方式适用于连接数目多且连接比较短(轻操作)的架构,比如聊天服务器,并发局限于应用中,编程比较复杂,JDK1.4开始支持. + +AIO方式使用于连接数目多且连接比较长(重操作)的架构,比如相册服务器,充分调用OS参与并发操作,编程比较复杂,JDK7开始支持. + +在server.xml中 + + + +实现对Tomcat的IO切换. + +## **2.** ***\*配置\**** + +参考链接: + +https://www.cnblogs.com/xuwc/p/8523681.html + + 配置文件 + server.xml:主要的配置文件。 + web.xml:缺省的web app配置,WEB-INF/web.xml会覆盖该配置。 + context.xml:不清楚跟server.xml里面的context是否有关系。 + + server.xml配置 + server标签 + port:指定一个端口,这个端口负责监听关闭tomcat的请求。 + shutdown:指定向端口发送的命令字符串。 + + service标签 + name:指定service的名字。 + + Connector(表示客户端和service之间的连接)标签 + +port:指定服务器端要创建的端口号,并在这个端口监听来自客户端的请求。 + minProcessors:服务器启动时创建的处理请求的线程数。 + maxProcessors:最大可以创建的处理请求的线程数。 + enableLookups:如果为true,则可以通过调用request.getRemoteHost()进行DNS查询来得到远程客户端的实际主机名,若为false则不进行DNS查询,而是返回其ip地址。 + redirectPort:指定服务器正在处理http请求时收到了一个SSL传输请求后重定向的端口号。 + acceptCount:指定当所有可以使用的处理请求的线程数都被使用时,可以放到处理队列中的请求数,超过这个数的请求将不予处理。 + connectionTimeout:指定超时的时间数(以毫秒为单位)。 + + Engine(表示指定service中的请求处理机,接收和处理来自Connector的请求)标签 + defaultHost:指定缺省的处理请求的主机名,它至少与其中的一个host元素的name属性值是一样的。 + + Context(表示一个web应用程序,通常为WAR文件,关于WAR的具体信息见servlet规范)标签 + docBase:该web应用的文档基准目录(Document Base,也称为Context Root),或者是WAR文件的路径。可以使用绝对路径,也可以使用相对于context所属的Host的appBase路径。 + path:表示此web应用程序的url的前缀,这样请求的url为http://localhost:8080/path/****。 + ***\*reloadable:这个属性非常重要,如果为true,则tomcat会自动检测应用程序的/WEB-INF/lib和/WEB-INF/classes目录的变化,自动装载新的应用程序,我们可以在不重起tomcat的情况下改变应用程序。\**** + useNaming:如果希望Catalina为该web应用使能一个JNDI InitialContext对象,设为true。该InitialialContext符合J2EE平台的约定,缺省值为true。 + workDir:Context提供的临时目录的路径,用于servlet的临时读/写。利用javax.servlet.context.tempdir属性,servlet可以访问该目录。如果没有指定,使用$CATALINA_HOME/work下一个合适的目录。 + swallowOutput:如果该值为true,System.out和System.err的输出被重定向到web应用的logger。如果没有指定,缺省值为false + debug:与这个Engine关联的Logger记录的调试信息的详细程度。数字越大,输出越详细。如果没有指定,缺省为0。 + + host(表示一个虚拟主机)标签 + name:指定主机名。 + appBase:应用程序基本目录,即存放应用程序的目录。 + unpackWARs:如果为true,则tomcat会自动将WAR文件解压,否则不解压,直接从WAR文件中运行应用程序。 + + Logger(表示日志,调试和错误信息)标签 + className:指定logger使用的类名,此类必须实现org.apache.catalina.Logger接口。 + prefix:指定log文件的前缀。 + suffix:指定log文件的后缀。 + timestamp:如果为true,则log文件名中要加入时间,如下例:localhost_log.2001-10-04.txt。 + + Realm(表示存放用户名,密码及role的数据库)标签 + className:指定Realm使用的类名,此类必须实现org.apache.catalina.Realm接口。 + + Valve(功能与Logger差不多,其prefix和suffix属性解释和Logger 中的一样)标签 + className:指定Valve使用的类名,如用org.apache.catalina.valves.AccessLogValve类可以记录应用程序的访问信息。 + directory:指定log文件存放的位置。 + pattern:有两个值,common方式记录远程主机名或ip地址,用户名,日期,第一行请求的字符串,HTTP响应代码,发送的字节数。combined方式比common方式记录的值更多。 + +# ***\*tomcat的安全配置:\**** + +https://blog.51cto.com/8248183/2062343 + + + +首次安装完成后立即删除webapps下面的所有代码 +rm -rf /srv/apache-tomcat/webapps/* +注释或删除 tomcat-users.xml 所有用户权限,看上去如下: + +# ***\*cat conf/tomcat-users.xml\**** + + + + + + +2、隐藏tomcat版本 +01.首先找到这个jar包,$TOMCAT_HOME/lib/catalina.jar +02.解压catalina.jar之后按照路径\org\apache\catalina\util\ServerInfo.properties找到文件 +03.打开ServerInfo.properties文件修改如下:把server.number、server.built置空 +server.info=Apache Tomcat +server.number= +server.built= +04.重新打成jar包,重启tomcat。 +3、隐藏tomcat 的服务类型 +conf/server.xml文件中,为connector元素添加server=" +",注意不是空字符串,是空格组成的长度为1的字符串,或者输入其他的服务类型,这时候,在response header中就没有server的信息啦! +4、应用程序安全 +关闭war自动部署 unpackWARs="false" autoDeploy="false"。防止被植入木马等恶意程序 +5、修改服务监听端口 +一般公司的 Tomcat 都是放在内网的,因此我们针对 Tomcat 服务的监听地址都是内网地址。 +修改实例: + + + + + +## 手写Tomcat + +参考连接: https://blog.csdn.net/weixin_39033443/article/details/83901722、https://www.cnblogs.com/jyroy/p/10778760.html + +### 主要步骤 + +HTTP 协议基本解析 + +处理 GET 或者 POST 请求逻辑 + +启动容器(socket) + + + + + + + + + diff --git a/study-tomcat/readme.docx b/study-tomcat/readme.docx deleted file mode 100644 index f4eab1684..000000000 Binary files a/study-tomcat/readme.docx and /dev/null differ diff --git a/study-utils/pom.xml b/study-utils/pom.xml index 8463cec56..087bc8a7b 100644 --- a/study-utils/pom.xml +++ b/study-utils/pom.xml @@ -12,6 +12,8 @@ http://maven.apache.org UTF-8 + 1.8 + 1.8 diff --git a/study-vue-npm/pom.xml b/study-vue-npm/pom.xml index 5792e1b86..770071e1f 100644 --- a/study-vue-npm/pom.xml +++ b/study-vue-npm/pom.xml @@ -17,8 +17,8 @@ UTF-8 - 1.7 - 1.7 + 1.8 + 1.8 diff --git a/study-vue/README-vue-mac.md b/study-vue/README-vue-mac.md new file mode 100644 index 000000000..2a6c23443 --- /dev/null +++ b/study-vue/README-vue-mac.md @@ -0,0 +1,135 @@ +# study-vue-Mac # + + +Mac 搭建vue环境 + +https://www.jianshu.com/p/a056e41833a7 + + + +## 安装HomeBrew + +https://docs.brew.sh + + + +安装 + +```bash +/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" +``` + + + +验证 + +```undefined +brew -v +``` + + + +异常处理 + +```undefined +==> Homebrew has enabled anonymous aggregate formulae and cask analytics. +Read the analytics documentation (and how to opt-out) here: + https://docs.brew.sh/Analytics +No analytics data has been sent yet (nor will any be during this install run). + +==> Homebrew is run entirely by unpaid volunteers. Please consider donating: + https://github.com/Homebrew/brew#donations + +==> Next steps: +- Run these two commands in your terminal to add Homebrew to your PATH: + echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/bage/.zprofile + eval "$(/opt/homebrew/bin/brew shellenv)" +- Run brew help to get started +- Further documentation: + https://docs.brew.sh +``` + + + +补充安装 + +```undefined +echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/bage/.zprofile + +eval "$(/opt/homebrew/bin/brew shellenv)" +``` + + + +## 安装 node + +安装 + +```undefined +brew install nodejs +``` + +验证 + +```undefined +node -v +``` + + + + + +## 安装 vue + +安装 + +```undefined +npm install --global vue-cli + +npm install --global vue-cli@3.0.1 + +npm config set registry https://registry.npm.taobao.org + +``` + +验证 + +```undefined +vue -V +``` + +适当更新版本 + +```undefined +npm install -g npm@8.10.0 +``` + + + +## 安装 yarn + +安装 + +```undefined +brew install yarn + +yarn global add vue-cli + +``` + +设置淘宝镜像 + +``` +yarn config set registry http://registry.npm.taobao.org/ + + +``` + +验证 + +```undefined +yarn -V +``` + + + diff --git a/study-vue/pom.xml b/study-vue/pom.xml index 805e5e186..0c50307df 100644 --- a/study-vue/pom.xml +++ b/study-vue/pom.xml @@ -17,8 +17,8 @@ UTF-8 - 1.7 - 1.7 + 1.8 + 1.8 diff --git a/study-websocket/pom.xml b/study-websocket/pom.xml index a7a577479..913c3cd24 100644 --- a/study-websocket/pom.xml +++ b/study-websocket/pom.xml @@ -18,6 +18,8 @@ UTF-8 + 1.8 + 1.8 2.0.1.RELEASE diff --git a/study-xfyun-lfasr/pom.xml b/study-xfyun-lfasr/pom.xml index 238af84c6..29d775872 100644 --- a/study-xfyun-lfasr/pom.xml +++ b/study-xfyun-lfasr/pom.xml @@ -17,8 +17,8 @@ UTF-8 - 1.7 - 1.7 + 1.8 + 1.8 diff --git a/study-xfyun-lfasr/src/main/java/com/bage/study/xfyun/lfasr/JsonParser.java b/study-xfyun-lfasr/src/main/java/com/bage/study/xfyun/lfasr/JsonParser.java index 40c826aa0..2f568914b 100644 --- a/study-xfyun-lfasr/src/main/java/com/bage/study/xfyun/lfasr/JsonParser.java +++ b/study-xfyun-lfasr/src/main/java/com/bage/study/xfyun/lfasr/JsonParser.java @@ -1,22 +1,22 @@ -package com.bage.study.xfyun.lfasr; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; - -public class JsonParser { - - public static String parseMessage(String data) { - JSONArray jsonArray = JSON.parseArray(data); - StringBuilder sb = new StringBuilder(); - JSONObject item = null; - for (int i = 0; i < jsonArray.size(); i++) { - item = jsonArray.getJSONObject(i); - if(item != null) { - sb.append(item.getString("onebest")); - } - } - return sb.toString(); - } - -} +//package com.bage.study.xfyun.lfasr; +// +//import com.alibaba.fastjson.JSON; +//import com.alibaba.fastjson.JSONArray; +//import com.alibaba.fastjson.JSONObject; +// +//public class JsonParser { +// +// public static String parseMessage(String data) { +// JSONArray jsonArray = JSON.parseArray(data); +// StringBuilder sb = new StringBuilder(); +// JSONObject item = null; +// for (int i = 0; i < jsonArray.size(); i++) { +// item = jsonArray.getJSONObject(i); +// if(item != null) { +// sb.append(item.getString("onebest")); +// } +// } +// return sb.toString(); +// } +// +//} diff --git a/study-xfyun-lfasr/src/main/java/com/bage/study/xfyun/lfasr/LfasrSDKDemo.java b/study-xfyun-lfasr/src/main/java/com/bage/study/xfyun/lfasr/LfasrSDKDemo.java index ad5db7779..96be95f91 100644 --- a/study-xfyun-lfasr/src/main/java/com/bage/study/xfyun/lfasr/LfasrSDKDemo.java +++ b/study-xfyun-lfasr/src/main/java/com/bage/study/xfyun/lfasr/LfasrSDKDemo.java @@ -1,133 +1,133 @@ -package com.bage.study.xfyun.lfasr; - -import com.alibaba.fastjson.JSON; -import com.iflytek.msp.cpdb.lfasr.client.LfasrClientImp; -import com.iflytek.msp.cpdb.lfasr.exception.LfasrException; -import com.iflytek.msp.cpdb.lfasr.model.LfasrType; -import com.iflytek.msp.cpdb.lfasr.model.Message; -import com.iflytek.msp.cpdb.lfasr.model.ProgressStatus; - -import java.io.File; -import java.util.HashMap; - -/** - * 非实时转写SDK调用demo - * 此demo只是一个简单的调用示例, 不适合用到实际生产环境中 - * - * @author white - * - */ -public class LfasrSDKDemo { - - // 原始音频存放地址 - private static final String local_file = "E:\\workspace\\IdeaProjects\\study\\study\\study-xfyun-lfasr\\target\\classes\\audio\\lfasr.wav"; - - /* - * 转写类型选择:标准版和电话版(旧版本, 不建议使用)分别为: - * LfasrType.LFASR_STANDARD_RECORDED_AUDIO 和 LfasrType.LFASR_TELEPHONY_RECORDED_AUDIO - * */ - private static final LfasrType type = LfasrType.LFASR_STANDARD_RECORDED_AUDIO; - - // 等待时长(毫秒) - private static int sleepMillis = 500; - - public static void main(String[] args) { - // 初始化LFASRClient实例 - LfasrClientImp lc = null; - try { - lc = LfasrClientImp.initLfasrClient(); - } catch (LfasrException e) { - // 初始化异常,解析异常描述信息 - Message initMsg = JSON.parseObject(e.getMessage(), Message.class); - System.out.println("ecode=" + initMsg.getErr_no()); - System.out.println("failed=" + initMsg.getFailed()); - } - - // 获取上传任务ID - String task_id = ""; - HashMap params = new HashMap(); - params.put("has_participle", "true"); - //合并后标准版开启电话版功能 - //params.put("has_seperate", "true"); - try { - // 上传音频文件 - Message uploadMsg = lc.lfasrUpload(local_file, type, params); - - // 判断返回值 - int ok = uploadMsg.getOk(); - if (ok == 0) { - // 创建任务成功 - task_id = uploadMsg.getData(); - System.out.println("task_id=" + task_id); - } else { - // 创建任务失败-服务端异常 - System.out.println("ecode=" + uploadMsg.getErr_no()); - System.out.println("failed=" + uploadMsg.getFailed()); - } - } catch (LfasrException e) { - // 上传异常,解析异常描述信息 - Message uploadMsg = JSON.parseObject(e.getMessage(), Message.class); - System.out.println("ecode=" + uploadMsg.getErr_no()); - System.out.println("failed=" + uploadMsg.getFailed()); - } - - // 循环等待音频处理结果 - while (true) { - try { - // 等待sleepMillis在获取任务进度 - Thread.sleep(sleepMillis); - System.out.println("waiting ..."); - } catch (InterruptedException e) { - e.printStackTrace(); - } - try { - // 获取处理进度 - Message progressMsg = lc.lfasrGetProgress(task_id); - - // 如果返回状态不等于0,则任务失败 - if (progressMsg.getOk() != 0) { - System.out.println("task was fail. task_id:" + task_id); - System.out.println("ecode=" + progressMsg.getErr_no()); - System.out.println("failed=" + progressMsg.getFailed()); - - return; - } else { - ProgressStatus progressStatus = JSON.parseObject(progressMsg.getData(), ProgressStatus.class); - if (progressStatus.getStatus() == 9) { - // 处理完成 - System.out.println("task was completed. task_id:" + task_id); - break; - } else { - // 未处理完成 - System.out.println("task is incomplete. task_id:" + task_id + ", status:" + progressStatus.getDesc()); - continue; - } - } - } catch (LfasrException e) { - // 获取进度异常处理,根据返回信息排查问题后,再次进行获取 - Message progressMsg = JSON.parseObject(e.getMessage(), Message.class); - System.out.println("ecode=" + progressMsg.getErr_no()); - System.out.println("failed=" + progressMsg.getFailed()); - } - } - - // 获取任务结果 - try { - Message resultMsg = lc.lfasrGetResult(task_id); - // 如果返回状态等于0,则获取任务结果成功 - if (resultMsg.getOk() == 0) { - // 打印转写结果 - System.out.println(JsonParser.parseMessage(resultMsg.getData())); - } else { - // 获取任务结果失败 - System.out.println("ecode=" + resultMsg.getErr_no()); - System.out.println("failed=" + resultMsg.getFailed()); - } - } catch (LfasrException e) { - // 获取结果异常处理,解析异常描述信息 - Message resultMsg = JSON.parseObject(e.getMessage(), Message.class); - System.out.println("ecode=" + resultMsg.getErr_no()); - System.out.println("failed=" + resultMsg.getFailed()); - } - } -} \ No newline at end of file +//package com.bage.study.xfyun.lfasr; +// +//import com.alibaba.fastjson.JSON; +//import com.iflytek.msp.cpdb.lfasr.client.LfasrClientImp; +//import com.iflytek.msp.cpdb.lfasr.exception.LfasrException; +//import com.iflytek.msp.cpdb.lfasr.model.LfasrType; +//import com.iflytek.msp.cpdb.lfasr.model.Message; +//import com.iflytek.msp.cpdb.lfasr.model.ProgressStatus; +// +//import java.io.File; +//import java.util.HashMap; +// +///** +// * 非实时转写SDK调用demo +// * 此demo只是一个简单的调用示例, 不适合用到实际生产环境中 +// * +// * @author white +// * +// */ +//public class LfasrSDKDemo { +// +// // 原始音频存放地址 +// private static final String local_file = "E:\\workspace\\IdeaProjects\\study\\study\\study-xfyun-lfasr\\target\\classes\\audio\\lfasr.wav"; +// +// /* +// * 转写类型选择:标准版和电话版(旧版本, 不建议使用)分别为: +// * LfasrType.LFASR_STANDARD_RECORDED_AUDIO 和 LfasrType.LFASR_TELEPHONY_RECORDED_AUDIO +// * */ +// private static final LfasrType type = LfasrType.LFASR_STANDARD_RECORDED_AUDIO; +// +// // 等待时长(毫秒) +// private static int sleepMillis = 500; +// +// public static void main(String[] args) { +// // 初始化LFASRClient实例 +// LfasrClientImp lc = null; +// try { +// lc = LfasrClientImp.initLfasrClient(); +// } catch (LfasrException e) { +// // 初始化异常,解析异常描述信息 +// Message initMsg = JSON.parseObject(e.getMessage(), Message.class); +// System.out.println("ecode=" + initMsg.getErr_no()); +// System.out.println("failed=" + initMsg.getFailed()); +// } +// +// // 获取上传任务ID +// String task_id = ""; +// HashMap params = new HashMap(); +// params.put("has_participle", "true"); +// //合并后标准版开启电话版功能 +// //params.put("has_seperate", "true"); +// try { +// // 上传音频文件 +// Message uploadMsg = lc.lfasrUpload(local_file, type, params); +// +// // 判断返回值 +// int ok = uploadMsg.getOk(); +// if (ok == 0) { +// // 创建任务成功 +// task_id = uploadMsg.getData(); +// System.out.println("task_id=" + task_id); +// } else { +// // 创建任务失败-服务端异常 +// System.out.println("ecode=" + uploadMsg.getErr_no()); +// System.out.println("failed=" + uploadMsg.getFailed()); +// } +// } catch (LfasrException e) { +// // 上传异常,解析异常描述信息 +// Message uploadMsg = JSON.parseObject(e.getMessage(), Message.class); +// System.out.println("ecode=" + uploadMsg.getErr_no()); +// System.out.println("failed=" + uploadMsg.getFailed()); +// } +// +// // 循环等待音频处理结果 +// while (true) { +// try { +// // 等待sleepMillis在获取任务进度 +// Thread.sleep(sleepMillis); +// System.out.println("waiting ..."); +// } catch (InterruptedException e) { +// e.printStackTrace(); +// } +// try { +// // 获取处理进度 +// Message progressMsg = lc.lfasrGetProgress(task_id); +// +// // 如果返回状态不等于0,则任务失败 +// if (progressMsg.getOk() != 0) { +// System.out.println("task was fail. task_id:" + task_id); +// System.out.println("ecode=" + progressMsg.getErr_no()); +// System.out.println("failed=" + progressMsg.getFailed()); +// +// return; +// } else { +// ProgressStatus progressStatus = JSON.parseObject(progressMsg.getData(), ProgressStatus.class); +// if (progressStatus.getStatus() == 9) { +// // 处理完成 +// System.out.println("task was completed. task_id:" + task_id); +// break; +// } else { +// // 未处理完成 +// System.out.println("task is incomplete. task_id:" + task_id + ", status:" + progressStatus.getDesc()); +// continue; +// } +// } +// } catch (LfasrException e) { +// // 获取进度异常处理,根据返回信息排查问题后,再次进行获取 +// Message progressMsg = JSON.parseObject(e.getMessage(), Message.class); +// System.out.println("ecode=" + progressMsg.getErr_no()); +// System.out.println("failed=" + progressMsg.getFailed()); +// } +// } +// +// // 获取任务结果 +// try { +// Message resultMsg = lc.lfasrGetResult(task_id); +// // 如果返回状态等于0,则获取任务结果成功 +// if (resultMsg.getOk() == 0) { +// // 打印转写结果 +// System.out.println(JsonParser.parseMessage(resultMsg.getData())); +// } else { +// // 获取任务结果失败 +// System.out.println("ecode=" + resultMsg.getErr_no()); +// System.out.println("failed=" + resultMsg.getFailed()); +// } +// } catch (LfasrException e) { +// // 获取结果异常处理,解析异常描述信息 +// Message resultMsg = JSON.parseObject(e.getMessage(), Message.class); +// System.out.println("ecode=" + resultMsg.getErr_no()); +// System.out.println("failed=" + resultMsg.getFailed()); +// } +// } +//} \ No newline at end of file diff --git a/study-xxl-job/pom.xml b/study-xxl-job/pom.xml index 89d7e3abd..200a02a8d 100644 --- a/study-xxl-job/pom.xml +++ b/study-xxl-job/pom.xml @@ -69,7 +69,7 @@ org.projectlombok lombok - 1.16.18 + 1.18.20 provided diff --git a/study-zipkin/pom.xml b/study-zipkin/pom.xml index 66da46201..932aea4c3 100644 --- a/study-zipkin/pom.xml +++ b/study-zipkin/pom.xml @@ -17,8 +17,8 @@ UTF-8 - 1.7 - 1.7 + 1.8 + 1.8 2.0.1.RELEASE 5.6.10