规范JAVA开发,Checkstyle使用

一. 统一编辑器格式化格式 下载code style 文件: code_style.xml IDEA 配置 在IntelliJ IDEA -> Preference -> Editor -> JAVA-> Code Style -> Java-> Scheme中,import code_style.xml 文件. 配置每次提交,进行自动format IntelliJ IDEA -> Preference -> Version Control -> Commit 中, 配置 Reformat Code 和 Optimize Imports 二. 使用Checkstyle工具 下载Checkstyle文件,放入项目checkstyle文件夹中: checkstyle.xml checkstyle-suppressionis.xml 在maven中,引入checkstyle插件 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 <plugin> <groupId>org....

November 15, 2022 · 1 min · BlackChen

CentOS 部署 Harbor

一. 部署 在一台CentOS上, 从零开始安装Harbor. 需要: Docker Docker-Compose Docker 安装 1. 配置YUM源 使用阿里云的源 1 2 yum install wget -y wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo 2. 安装最新版本Docker 1 yum install docker-ce docker-ce-cli -y 3. 修改Docker 配置文件 1 2 3 4 5 6 7 8 9 10 11 12 mkdir /etc/docker/ cat > /etc/docker/daemon.json << EOF { "registry-mirrors": ["https://gqs7xcfd.mirror.aliyuncs.com","https://hub-mirror.c.163.com"], "exec-opts": ["native.cgroupdriver=systemd"], "log-driver": "json-file", "log-opts": { "max-size": "100m" }, "storage-driver": "overlay2" } EOF 4. 启动Docker 服务 1 systemctl daemon-reload && systemctl enable docker && systemctl start docker 5....

October 18, 2022 · 2 min · BlackChen

VsCode 小技巧

删除不匹配某字符串的行 删除不包含private字符串的行. ^((?!private).)*$ 删除匹配某字符串的行 删除包含ffep字符串的行 ^.*(ffep).*\n 删除空行 ^\s*(?=\r?$)\n

July 28, 2022 · 1 min · BlackChen

mermaid 在HUGO中使用

Hugo配置 配置Hugo ShortCode 在主题目录/layouts/shortcodes, 新增mermaid.html 1 2 {{ $_hugo_config := `{ "version": 1 }` }} <div class="mermaid" align="{{ if .Get "align" }}{{ .Get "align" }}{{ else }}center{{ end }}">{{ safeHTML .Inner }}</div> 修改/layouts/partials/footer.html,新增如下配置 1 2 3 4 5 6 <script src="https://unpkg.com/mermaid@8.8.1/dist/mermaid.min.js"></script> <script> Array.from(document.getElementsByClassName('language-mermaid')).forEach(el => { el.parentElement.outerHTML = `<div class="mermaid">${el.innerText}</div>` }) </script> hugo 中使用mermaid 在写文章的时候, 使用{ {<mermaid>} } 和 { {</mermaid>} } 包围相应的代码即可 案例 (mermaid 官网)[https://mermaid-js.github.io/mermaid/#/] Flowchart 1 2 3 4 5 graph TD; A-->B; A-->C; B-->D; C-->D; graph TD; A-->B; A-->C; B-->D; C-->D; Sequence diagram 1 2 3 4 5 6 7 8 9 10 11 sequenceDiagram participant Alice participant Bob Alice->>John: Hello John, how are you?...

July 24, 2022 · 2 min · BlackChen

Out Of Memory

一. JVM Out Of Memory 相关参数 1 2 3 4 5 -XX:+HeapDumpOnOutOfMemoryError -XX:+HeapDumpPath -XX:OnOutOfMemoryError -XX:+ExitOnOutOfMemoryError -XX:+CrashOnOutOfMemoryError -XX:+HeapDumpOnOutOfMemoryError 和-XX:+HeapDumpPath -XX:+HeapDumpOnOutOfMemoryError代表在发生内存溢出时,生成堆转储文件. 一般配合 -XX:+HeapDumpPath使用, 指定输出的目录或文件. 例如: 在发生内存溢出时,会生成如下文件: 同时, 会产生如下日志: 1 2 3 4 5 6 7 ava.lang.OutOfMemoryError: Java heap space Dumping heap to /Users/chen/dump-file/java_pid86050.hprof ... Heap dump file created [179875659 bytes in 0.587 secs] [2022-07-12 23:23:12.463] [http-nio-64222-exec-1] [TxId : , SpanId : ] [ERROR] c.r.common.config.webmvc.RestExceptionHandler - GlobalExceptionHandler handleException error org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java....

July 11, 2022 · 5 min · BlackChen