Windows下创建Redis服务
1 | ./redis-server.exe --service-install D:\develop\Redis-x64-5.0.14.1\redis.conf |
1 | ./redis-server.exe --service-install D:\develop\Redis-x64-5.0.14.1\redis.conf |
下面描述三种类型
application/x-www-form-urlencoded
multipart/form-data
:上传文件application/json;charset=UTF-8
Post
1 | @Slf4j |
1 | JSONObject body = response.getBody(); |
1 | REST_TEMPLATE.setErrorHandler(new DefaultResponseErrorHandler() { |
HttpClient
1 | <dependencies> |
1 | import lombok.extern.slf4j.Slf4j; |
1 | REST_TEMPLATE.setErrorHandler(new DefaultResponseErrorHandler() { |
Word
文档内容识别主要由两部分:doc
、docx
docx
文档内容识别的难点在于:
下面记录解析段落格式及内容。
docx
内容提取提取全文内容相对简单
1 | public class FileParsingService { |
提取有格式的内容是按照段的方式提取的。
1 | public class FileParsingService { |
常用的几种段类型:
XWPFSDT
目录XWPFParagraph
段落XWPFTable
表格XWPFSDT
目录对于目录,直接获取目录内容就可以了
1 | ((XWPFSDT) bodyElement).getContent().getText() |
XWPFParagraph
段落(重点)作为段落的内容,又可以分为:
1 | public class FileParsingUtil { |
1 | XWPFParagraph paragraphTemp = (XWPFParagraph) bodyElement; |
格式有很多,比如:
Heading 1
Heading 2
RegHChG
RegH1G
RegH2G
ListParagraph
RegSingleTxtG
RegSingleTxtG2
备注:但是需要的判断方式不是序列的格式,因为格式是不固定的。
格式内容在
wps
的样式和格式中都能看到。
1 | XWPFParagraph paragraphTemp = (XWPFParagraph) bodyElement; |
需要有两个重要属性
NumLevelText
序列值的格式化方式%1、
,根据序列的类型,可以为 1、
,一、
,a、
等(%1)
,根据序列的类型,可以为 (1)
,(一)
,(a)
等%1
与 %2
的区别——TODO
NumFmt
序列的类型chineseCounting
中文decimal
数字decimalEnclosedCircleChinese
圆圈中的数字upperLetter
大写字母lowerLetter
小写字母lowerRoman
小写罗马upperRoman
大写罗马bullet
无序(不用识别出方的、圆的和菱形的,没有意义)XWPFTable
表格1 | public class FileParsingUtil { |
一段话:
在识别出内容出现的规律后,对于规范的格式,需要识别的内容也是多种多样的,需要打开 word
(docx
推荐用wps
打开),然后打开样式和格式,对每个段落内容进行分析。
1 | import java.util.HashMap; |
SpringCloudGateway
全局过滤器需要实现 org.springframework.cloud.gateway.filter.GlobalFilter
接口。
1 |
|
Sentinel
官方配置记录了一部分,在 sentinel-core
的源码里都可以找到。
sentinel-dashbord
控制台这里使用
sentinel-dashboard-1.8.6.jar
这里建议使用外部化配置:
1 | java -Dcsp.sentinel.config.file=./application.properties -jar sentinel-dashboard.jar |
配置文件在 sentinel-dashboard.jar:/BOOT-INF/classes/application.properties
,内容如下:
1 | # 新增 |
sentinel
客户端日志配置 sentinel.properties
加载是在 LogConfigLoader
下,加载方式有
CSP_SENTINEL_CONFIG_FILE
)指定csp.sentinel.config.file
)指定classpath:sentinel.properties
)我们可以使用默认配置,在 resources
下创建 sentinel.properties
文件:
1 | # 没有配置时,默认读取当前文件,可以通过 -Dcsp.sentinel.config.file 配置 |
如果使用 SpringCloudAlibaba
,可以参考官方 Sentinel
说明
这里使用SpringCloud
。
父类依赖
1 | <!-- <spring-cloud.version>2021.0.4</spring-cloud.version> --> |
基础依赖
1 | <!-- SpringCloud Alibaba Sentinel --> |
sentinel
使用 nacos
做配置中心
1 | <!-- Sentinel Datasource Nacos --> |
sentinel
与 gateway
依赖
1 | <!-- SpringCloud Alibaba Sentinel Gateway --> |
1 | # Spring |
ruleType
):flow
的配置nacos
配置中心就可以添加网关流量控制规则:
1 | [ |
网关限流规则:GatewayFlowRule
在 nginx.conf
的 http
下加入:
1 | # 开启gzip压缩 |