Skip to content

Commit f99ceb1

Browse files
committed
推包包含 Git 信息, Docker 等
1 parent c9f89ef commit f99ceb1

File tree

17 files changed

+222
-10
lines changed

17 files changed

+222
-10
lines changed

Diff for: DevOps/CI.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
### 设置最后封板时间并严守,以便有足够的时间编译程序包做回归测试
44

5-
5+
### 编译日志同时保存到文件后用工具解析出错行作者,根据时间倒序发邮件
6+
`2>&1|tee maven.log`
67

78
### 任何脚本运行的操作都要搜下是否有乱码的可能
89

@@ -12,12 +13,11 @@
1213

1314
- 标签不支持空格和冒号,不能用`yyyy-MM-dd HH:mm:ss`
1415
- 空格换成下划线的话双击时会连带选择
15-
- 逗号常用于分割符
16-
- 如果是比较高的符号会影响视觉分隔效果
17-
- 虽然大写更有美感也符合转悠名词的习惯\
16+
- 但是是较高的符号会影响视觉分隔效果,所以用下划线
17+
- 英文逗号常用于分割符,所以用英文句号
18+
- 虽然大写更有美感也符合专有名词的习惯\
1819
但在输入时不便,视觉辨识度也较低,所以用小写
1920

20-
所以用下划线:
2121
```
2222
prd_yyyy-mm-dd_hh.mm.ss
2323
其中:

Diff for: DevOps/Nginx.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
# Nginx
22

3+
### 使用 alias 便于本地文件夹可以不用和 location 同名
4+
- root,实际的路径就是:root值 + location值。
5+
- alias,实际的路径就是:alias值。
6+
37
### 不要用 root 启动避免后面非 root 报 Premature EOF
48

59
在 nginx.conf 中配置 user 启动用户
610

11+
### 修复漏洞更新时不用重启命令
12+
访问 404 网页看到的仍是旧版
13+
714
### 设置 Nginx 的 body 大小避免请求失败
815
```
916
client_max_body_size 8m;

Diff for: DevOps/docker/Docker_CentOS7.md

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Docker CentOS 7 常用设置
2+
3+
### centos8 停止维护,所以下 7
4+
```
5+
docker pull centos:centos7
6+
```
7+
阿里云yum(centos7不用也行):http://mirrors.aliyun.com/repo/
8+
9+
### 特权启动设置时区
10+
避免报错 Failed to get D-Bus connection: Operation not permitted
11+
```
12+
docker run -d --name centos7 --privileged=true centos:centos7 /usr/sbin/init -e TZ=Asia/Shanghai
13+
```
14+
15+
### 同步阿里云时间
16+
```
17+
timedatectl set-timezone Asia/Shanghai
18+
yum install ntpdate -y
19+
ntpdate ntp.aliyun.com
20+
```
21+
22+
### 安装 locate 命令并初始化
23+
```
24+
yum install mlocate -y
25+
updatedb
26+
```
27+
28+
### 别自己编译 gcc,会遇到很多问题
29+
安装并切换到 gcc 11 环境
30+
```
31+
yum install -y http://mirror.centos.org/centos/7/extras/x86_64/Packages/centos-release-scl-rh-2-3.el7.centos.noarch.rpm
32+
yum install -y http://mirror.centos.org/centos/7/extras/x86_64/Packages/centos-release-scl-2-3.el7.centos.noarch.rpm
33+
yum install devtoolset-11-gcc-c++
34+
scl enable devtoolset-11 bash
35+
```
36+
如果以后都用 gcc 11 可以改下链接
37+
```
38+
mv /usr/bin/gcc /usr/bin/gcc-4.8.5
39+
ln -s /opt/rh/devtoolset-11/root/bin/gcc /usr/bin/gcc
40+
```

Diff for: DevOps/docker/Docker_Win.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Docker Windows 版
2+
3+
### 安装云缓存的旧版,避免新版各种启动失败
4+
https://mirrors.aliyun.com/docker-toolbox/windows/docker-for-windows/stable
5+
6+
```json
7+
{
8+
"builder": {
9+
"gc": {
10+
"defaultKeepStorage": "20GB",
11+
"enabled": true
12+
}
13+
},
14+
"experimental": false,
15+
"features": {
16+
"buildkit": true
17+
},
18+
"registry-mirrors": [
19+
"http://hub-mirror.c.163.com",
20+
"https://docker.mirrors.ustc.edu.cn",
21+
"https://registry.docker-cn.com",
22+
"https://6kx4zyno.mirror.aliyuncs.com"
23+
]
24+
}
25+
```

Diff for: DevOps/docker/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Docker
2+

Diff for: DevOps/linux/sh_mnemonic.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ grep "行标识字符" pom.xml
2121
# 助记语:你不替食堂熬汤
2222
nbtstat -A IP
2323
```
24-
24+
2525

2626
## 端口查进程
2727
```batch

Diff for: business/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# 业务应用

Diff for: db/SQL.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# SQL
22

3+
### 比较时都用字符串比较,MyBatis 用 #{} 自动加引号,避免类似 1='1xxx' 成立导致问题
4+
35
### `INSERT`语句建议在工具上编辑好值后使用将所选行导出为`INSERT`语句的方式
46

57
在工具中编辑是为了方便在图形界面中观察每条记录的差别,导出的语句方便也避免了繁琐的语法编辑和错漏。

Diff for: db/comment/Oracle_comment.sql

+9-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,12 @@ COMMENT ON COLUMN TEST.COMMON_SEQ.APP_CODE IS '应用编码';
88
SELECT * FROM SYS.ALL_TAB_COMMENTS WHERE OWNER = '库名' AND COMMENTS IS NULL;
99

1010
-- 查询所有没注释的列
11-
SELECT * FROM SYS.ALL_COL_COMMENTS WHERE OWNER = '库名' AND COMMENTS IS NULL;
11+
SELECT * FROM SYS.ALL_COL_COMMENTS WHERE OWNER = '库名' AND COMMENTS IS NULL;
12+
13+
-- 表注释转语句 同步注释用
14+
SELECT 'COMMENT ON TABLE '||OWNER||'.'||TABLE_NAME||' IS '''||COMMENTS||''';'
15+
FROM SYS.ALL_TAB_COMMENTS WHERE OWNER = '库名' AND COMMENTS IS NOT NULL;
16+
17+
-- 列注释转语句 同步注释用
18+
SELECT 'COMMENT ON COLUMN '||OWNER||'.'||TABLE_NAME||'.'||COLUMN_NAME||' IS '''||COMMENTS||''';'
19+
FROM SYS.ALL_COL_COMMENTS WHERE OWNER = '库名' AND COMMENTS IS NOT NULL;

Diff for: db/transaction.md

+6
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,9 @@
6464
| 重入 | | MAC + jvm进程ID + 线程ID | 与当前最小节点对比 |
6565
| 单点 | | 集群部署 | 集群部署 |
6666

67+
68+
## 分布式事务
69+
70+
- 分支事务执行时要拒绝回滚执行
71+
- 已经失败的事务直接返回回滚成功
72+
- 多次收到分支事务要幂等

Diff for: java/java_framework/springboot/common/AfterRun.java

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package io.github.linwancen.app;
2+
3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
5+
import org.springframework.beans.factory.annotation.Value;
6+
import org.springframework.boot.CommandLineRunner;
7+
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
8+
import org.springframework.stereotype.Component;
9+
10+
import javax.servlet.ServletContext;
11+
import java.net.InetAddress;
12+
import java.net.UnknownHostException;
13+
14+
/**
15+
* 启动后打印访问地址
16+
* <br>
17+
* <br>如果需要更复杂的参数可以使用 {@link org.springframework.boot.ApplicationRunner}
18+
*/
19+
@Component
20+
public class AfterRun implements CommandLineRunner {
21+
private static final Logger LOGGER = LoggerFactory.getLogger(AfterRun.class);
22+
23+
public static final String LOCAL_IP;
24+
25+
static {
26+
String ip;
27+
try {
28+
ip = InetAddress.getLocalHost().getHostAddress();
29+
} catch (UnknownHostException e) {
30+
ip = "0.0.0.0";
31+
}
32+
LOCAL_IP = ip;
33+
}
34+
35+
private final ServletWebServerApplicationContext servletWebServerApplicationContext;
36+
37+
public AfterRun(ServletWebServerApplicationContext servletWebServerApplicationContext) {
38+
this.servletWebServerApplicationContext = servletWebServerApplicationContext;
39+
}
40+
41+
@Value("${spring.application.name:}")
42+
private String name;
43+
@Value("${spring.profiles.active:}")
44+
private String profile;
45+
46+
@Override
47+
public void run(String... args) {
48+
int port = servletWebServerApplicationContext.getWebServer().getPort();
49+
ServletContext servletContext = servletWebServerApplicationContext.getServletContext();
50+
String contextPath = servletContext == null ? "" : servletContext.getContextPath();
51+
//noinspection HttpUrlsUsage
52+
LOGGER.info("服务启动完毕 start complete {} {} http://{}:{}{}", name, profile, LOCAL_IP, port, contextPath);
53+
LOGGER.info("本地访问地址 http://localhost:{}{}", port, contextPath);
54+
}
55+
}

Diff for: java/jdk/Java_reflection.md

+14-1
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,17 @@ main 方法可以继承运行,不算重写(不能`@Override`)
4242

4343
### 使用 JDK 自带的类来做解析工具的接口返回
4444

45-
一些常量或类型可以用诸如`Modifier``ElementType`的定义
45+
一些常量或类型可以用诸如`Modifier``ElementType`的定义
46+
47+
### 不要使用`ClassLoader`获取类路径以免空指针异常
48+
49+
```java
50+
class A { void fun() {
51+
Main.class.getResource(""); // 该类包路径 √
52+
Main.class.getResource("/"); // 根路径 √
53+
ClassLoader.getSystemResource("");// 类的根路径,classpath file 模式下为 null
54+
ClassLoader.getSystemResource("/"); // null
55+
Main.class.getClassLoader().getResource(""); // 根路径
56+
Main.class.getClassLoader().getResource ("/"); // null
57+
}}
58+
```

Diff for: log/PathUtils.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ private PathUtils() {}
1616

1717
static {
1818
@SuppressWarnings("ConstantConditions")
19-
String path = ClassLoader.getSystemClassLoader().getResource("").getPath();
19+
String path = PathUtils.class.getResource("/").getPath();
2020
try {
2121
path = URLDecoder.decode(path, "UTF-8");
2222
} catch (Exception ignored) {

Diff for: maven/Maven_deploy.md

+39
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
</properties>
1313
```
1414

15+
1516
### 一般情况下应推送源码和文档,便于依赖方研究如何使用和排查问题
1617

1718
推送源码官方参考:http://maven.apache.org/plugins/maven-source-plugin/usage.html
@@ -42,6 +43,44 @@
4243
```
4344

4445

46+
### 应在包中包含 Git 信息方便在没有 Git Tag 的时候找到对应版本
47+
48+
打包Git信息官方参考:https://github.com/git-commit-id/git-commit-id-maven-plugin
49+
50+
```xml
51+
<project>
52+
...
53+
<build>
54+
<plugins>
55+
<plugin>
56+
<groupId>io.github.git-commit-id</groupId>
57+
<artifactId>git-commit-id-maven-plugin</artifactId>
58+
<version>4.9.9</version>
59+
<executions>
60+
<execution>
61+
<id>git-commit-id</id>
62+
<phase>initialize</phase>
63+
<goals>
64+
<goal>revision</goal>
65+
</goals>
66+
</execution>
67+
</executions>
68+
<configuration>
69+
<dateFormat>yyyy-MM-dd HH:mm:ss</dateFormat>
70+
<generateGitPropertiesFile>true</generateGitPropertiesFile>
71+
<generateGitPropertiesFilename>${project.build.outputDirectory}/git.json</generateGitPropertiesFilename>
72+
<format>json</format>
73+
<failOnNoGitDirectory>false</failOnNoGitDirectory>
74+
<failOnUnableToExtractRepoInfo>false</failOnUnableToExtractRepoInfo>
75+
</configuration>
76+
</plugin>
77+
</plugins>
78+
</build>
79+
...
80+
</project>
81+
```
82+
83+
4584
### 推送私服用命令行代替 distributionManagement 配置
4685

4786
```shell script

Diff for: pm/README.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# 项目管理
2+
3+
4+
## Excel 应用
5+
6+
### 使用在线 Excel 而不是离线方便统一修改更新
7+
8+
### 通过表名拼接的形式设计统计表
9+
```
10+
=COUNTA(INDIRECT("'"&$A2&"'!"&"$G:$G"))-1
11+
=COUNTIF(INDIRECT("'"&$A2&"'!"&"$G:$G"), B$1)
12+
```
13+
14+
### 需统计完成时间的可以用`Ctrl + ;`输入日期代表完成

Diff for: regexp/RegExpOpti.md

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
正则表达式优化
21
# 正则表达式优化
32

43
《精通正则表达式》总结

Diff for: web/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# 前端

0 commit comments

Comments
 (0)