Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a8012e2

Browse files
Java:3 个 Demo 预防在 接入且启用 UnitAuto 后泄漏 SQLConfig 的 dbUri, dbAccount, dbPassword - fastjson 的 @JSONField 只限实例类生效,在父类注解无效
1 parent 4749bda commit a8012e2

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

‎APIJSON-Java-Server/APIJSONBoot/src/main/java/apijson/demo/DemoSQLConfig.java‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import static apijson.framework.APIJSONConstant.USER_;
2020
import static apijson.framework.APIJSONConstant.USER_ID;
2121

22+
import com.alibaba.fastjson.annotation.JSONField;
23+
2224
import apijson.RequestMethod;
2325
import apijson.framework.APIJSONSQLConfig;
2426
import apijson.orm.AbstractSQLConfig;
@@ -118,6 +120,8 @@ public String getDBVersion() {
118120
}
119121
return null;
120122
}
123+
124+
@JSONField(serialize = false) // 不在日志打印 账号/密码 等敏感信息,用了 UnitAuto 则一定要加
121125
@Override
122126
public String getDBUri() {
123127
if (isMySQL()) {
@@ -139,6 +143,8 @@ public String getDBUri() {
139143
}
140144
return null;
141145
}
146+
147+
@JSONField(serialize = false) // 不在日志打印 账号/密码 等敏感信息,用了 UnitAuto 则一定要加
142148
@Override
143149
public String getDBAccount() {
144150
if (isMySQL()) {
@@ -158,6 +164,8 @@ public String getDBAccount() {
158164
}
159165
return null;
160166
}
167+
168+
@JSONField(serialize = false) // 不在日志打印 账号/密码 等敏感信息,用了 UnitAuto 则一定要加
161169
@Override
162170
public String getDBPassword() {
163171
if (isMySQL()) {

‎APIJSON-Java-Server/APIJSONDemo/src/main/java/apijson/demo/DemoSQLConfig.java‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
package apijson.demo;
1616

17+
import com.alibaba.fastjson.annotation.JSONField;
18+
1719
import apijson.framework.APIJSONSQLConfig;
1820

1921

@@ -42,14 +44,20 @@ public class DemoSQLConfig extends APIJSONSQLConfig {
4244
public String getDBVersion() {
4345
return "5.7.22"; // "8.0.11"; // TODO 改成你自己的 MySQL 或 PostgreSQL 数据库版本号 // MYSQL 8 和 7 使用的 JDBC 配置不一样
4446
}
47+
48+
@JSONField(serialize = false) // 不在日志打印 账号/密码 等敏感信息
4549
@Override
4650
public String getDBUri() {
4751
return "jdbc:mysql://localhost:3306"; // TODO 改成你自己的,TiDB 可以当成 MySQL 使用,默认端口为 4000
4852
}
53+
54+
@JSONField(serialize = false) // 不在日志打印 账号/密码 等敏感信息
4955
@Override
5056
public String getDBAccount() {
5157
return "root"; // TODO 改成你自己的
5258
}
59+
60+
@JSONField(serialize = false) // 不在日志打印 账号/密码 等敏感信息
5361
@Override
5462
public String getDBPassword() {
5563
return "apijson"; // TODO 改成你自己的,TiDB 可以当成 MySQL 使用, 默认密码为空字符串 ""

‎APIJSON-Java-Server/APIJSONFinal/src/main/java/apijson/demo/DemoSQLConfig.java‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import static apijson.framework.APIJSONConstant.USER_;
2020
import static apijson.framework.APIJSONConstant.USER_ID;
2121

22+
import com.alibaba.fastjson.annotation.JSONField;
23+
2224
import apijson.RequestMethod;
2325
import apijson.framework.APIJSONSQLConfig;
2426
import apijson.orm.AbstractSQLConfig;
@@ -109,6 +111,8 @@ public String getDBVersion() {
109111
}
110112
return null;
111113
}
114+
115+
@JSONField(serialize = false) // 不在日志打印 账号/密码 等敏感信息,用了 UnitAuto 则一定要加
112116
@Override
113117
public String getDBUri() {
114118
if (isMySQL()) {
@@ -128,6 +132,8 @@ public String getDBUri() {
128132
}
129133
return null;
130134
}
135+
136+
@JSONField(serialize = false) // 不在日志打印 账号/密码 等敏感信息,用了 UnitAuto 则一定要加
131137
@Override
132138
public String getDBAccount() {
133139
if (isMySQL()) {
@@ -147,6 +153,8 @@ public String getDBAccount() {
147153
}
148154
return null;
149155
}
156+
157+
@JSONField(serialize = false) // 不在日志打印 账号/密码 等敏感信息,用了 UnitAuto 则一定要加
150158
@Override
151159
public String getDBPassword() {
152160
if (isMySQL()) {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /