From ed80e3fa8ae1909b2f8f667c17ddf1a0bfdc859a Mon Sep 17 00:00:00 2001 From: HuangXin Date: Sun, 27 Sep 2020 18:16:29 +0800 Subject: [PATCH] =?UTF-8?q?OCT=20REM:=201.=20=E4=BF=AE=E6=AD=A3=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E8=B4=A8=E9=87=8F=E6=A3=80=E6=9F=A5=E9=94=99=E8=AF=AF?= =?UTF-8?q?=202.=20=E6=9B=B4=E6=96=B0=E6=8C=81=E7=BB=AD=E9=9B=86=E6=88=90?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E7=9A=84MySQL=E6=9C=8D=E5=8A=A1=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/application-test.properties | 16 ++++++------ .../config/CfgFileSecurityConfigure.java | 26 ++++++++++++------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/config/application-test.properties b/config/application-test.properties index 715351d4..77de0ca5 100644 --- a/config/application-test.properties +++ b/config/application-test.properties @@ -4,15 +4,15 @@ server.tomcat.basedir=./basedir # 多个项目放在nginx下同个端口,通过该配置区分 server.servlet.context-path=/dispose # 配置数据源 -spring.datasource.url=jdbc:mysql://10.88.77.65:33061/ci_dispose_v2?serverTimezone=Asia/Shanghai&zeroDateTimeBehavior\ - =convertToNull&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true -spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver -spring.datasource.username=root -spring.datasource.password=h0K0_8u -#spring.datasource.url=jdbc:mysql://172.28.72.118:33061/ci_dispose_v2?serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull&useUnicode=true +#spring.datasource.url=jdbc:mysql://10.88.77.65:33061/ci_dispose_v2?serverTimezone=Asia/Shanghai&zeroDateTimeBehavior\ +# =convertToNull&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true #spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver -#spring.datasource.username=phoenix -#spring.datasource.password=ENC@yr1dDL7FO8J642rqx5sD7Q== +#spring.datasource.username=root +#spring.datasource.password=h0K0_8u +spring.datasource.url=jdbc:mysql://172.28.72.118:33061/ci_dispose_v2?serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull&useUnicode=true +spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver +spring.datasource.username=phoenix +spring.datasource.password=Hy@rfph32 # 配置连接池 spring.datasource.schema=classpath:test_db/unit_test.sql diff --git a/src/main/java/com/dispose/config/CfgFileSecurityConfigure.java b/src/main/java/com/dispose/config/CfgFileSecurityConfigure.java index bbb56efd..b00793ad 100644 --- a/src/main/java/com/dispose/config/CfgFileSecurityConfigure.java +++ b/src/main/java/com/dispose/config/CfgFileSecurityConfigure.java @@ -28,21 +28,27 @@ public class CfgFileSecurityConfigure { public EncryptionPropertyResolver encryptablePropertyResolver() throws IOException { InputStream is = ClassLoader.getSystemResourceAsStream("git.properties"); assert is != null; + BufferedReader reader = new BufferedReader(new InputStreamReader(is)); String password = ""; - BufferedReader reader = new BufferedReader(new InputStreamReader(is)); - log.info("Version Information:"); - while (true) { - String val = reader.readLine(); - log.info("{}", val); + try { + log.info("Version Information:"); + while (true) { + String val = reader.readLine(); + log.info("{}", val); - if (val == null) { - break; - } + if (val == null) { + break; + } - if (val.startsWith("git.commit.id=")) { - password = val.substring("git.commit.id=".length()); + if (val.startsWith("git.commit.id=")) { + password = val.substring("git.commit.id=".length()); + } } + } catch (IOException ex) { + log.error("EncryptablePropertyResolver exception, used default password"); + } finally { + reader.close(); } return new EncryptionPropertyResolver(password);