diff --git a/.gitignore b/.gitignore index 8aa9c4c7..e253499d 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,4 @@ gen # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* +mbg.xml \ No newline at end of file diff --git a/ht/src/main/resources/druid-prod.yml b/ht/src/main/resources/druid-prod.yml index 870134f0..6e398be8 100644 --- a/ht/src/main/resources/druid-prod.yml +++ b/ht/src/main/resources/druid-prod.yml @@ -15,7 +15,7 @@ spring: maxWait: 60000 minEvictableIdleTimeMillis: 300000 minIdle: 5 - password: po3OynBO[M3579p6L7)o + password: poolPreparedStatements: true servletLogSlowSql: true servletLoginPassword: 111111 @@ -27,7 +27,7 @@ spring: testOnReturn: false testWhileIdle: true timeBetweenEvictionRunsMillis: 60000 - url: jdbc:mysql://api.ccsens.com/pt_pro?useUnicode=true&characterEncoding=UTF-8 + url: jdbc:mysql://127.0.0.1/pt_pro?useUnicode=true&characterEncoding=UTF-8 username: root validationQuery: SELECT 1 FROM DUAL env: CCSENS_HT \ No newline at end of file diff --git a/ht/src/main/resources/druid-test.yml b/ht/src/main/resources/druid-test.yml index d882c636..f3fe04c5 100644 --- a/ht/src/main/resources/druid-test.yml +++ b/ht/src/main/resources/druid-test.yml @@ -15,7 +15,7 @@ spring: maxWait: 60000 minEvictableIdleTimeMillis: 300000 minIdle: 5 - password: c011b9b90306f0b9e24362519176551f5f9be6b4130ad2834b92c3a468273ed5 + password: poolPreparedStatements: true servletLogSlowSql: true servletLoginPassword: 111111 @@ -27,7 +27,7 @@ spring: testOnReturn: false testWhileIdle: true timeBetweenEvictionRunsMillis: 60000 - url: jdbc:mysql://49.233.89.188:3306/ht?useUnicode=true&characterEncoding=UTF-8 + url: jdbc:mysql://127.0.0.1/ht?useUnicode=true&characterEncoding=UTF-8 username: root validationQuery: SELECT 1 FROM DUAL env: CCSENS_HT \ No newline at end of file diff --git a/tall/src/main/resources/druid-prod.yml b/tall/src/main/resources/druid-prod.yml index d62f9205..4ac2d7a2 100644 --- a/tall/src/main/resources/druid-prod.yml +++ b/tall/src/main/resources/druid-prod.yml @@ -15,7 +15,7 @@ spring: maxWait: 60000 minEvictableIdleTimeMillis: 300000 minIdle: 5 - password: po3OynBO[M3579p6L7)o + password: poolPreparedStatements: true servletLogSlowSql: true servletLoginPassword: 111111 @@ -27,7 +27,7 @@ spring: testOnReturn: false testWhileIdle: true timeBetweenEvictionRunsMillis: 60000 - url: jdbc:mysql://api.ccsens.com/pt_pro?useUnicode=true&characterEncoding=UTF-8 + url: jdbc:mysql://127.0.0.1/pt_pro?useUnicode=true&characterEncoding=UTF-8 username: root validationQuery: SELECT 1 FROM DUAL env: CCSENS_TALL \ No newline at end of file diff --git a/tall/src/main/resources/druid-test.yml b/tall/src/main/resources/druid-test.yml index c00d4f86..0452b17f 100644 --- a/tall/src/main/resources/druid-test.yml +++ b/tall/src/main/resources/druid-test.yml @@ -15,7 +15,7 @@ spring: maxWait: 60000 minEvictableIdleTimeMillis: 300000 minIdle: 5 - password: 25e15ffd05a0123690625e1817563ba75fbd93016d888c84fbb4c849b58dafeb + password: poolPreparedStatements: true servletLogSlowSql: true servletLoginPassword: 111111 @@ -27,7 +27,7 @@ spring: testOnReturn: false testWhileIdle: true timeBetweenEvictionRunsMillis: 60000 - url: jdbc:mysql://49.233.89.188:3306/tall?useUnicode=true&characterEncoding=UTF-8 + url: jdbc:mysql://127.0.0.1/tall?useUnicode=true&characterEncoding=UTF-8 username: root validationQuery: SELECT 1 FROM DUAL env: CCSENS_TALL \ No newline at end of file diff --git a/util/src/main/java/com/ccsens/util/config/DruidProps.java b/util/src/main/java/com/ccsens/util/config/DruidProps.java index ca6b061b..8f50f090 100644 --- a/util/src/main/java/com/ccsens/util/config/DruidProps.java +++ b/util/src/main/java/com/ccsens/util/config/DruidProps.java @@ -2,6 +2,7 @@ package com.ccsens.util.config; import cn.hutool.core.codec.Base64; import cn.hutool.core.util.CharsetUtil; +import cn.hutool.core.util.StrUtil; import cn.hutool.crypto.symmetric.SymmetricAlgorithm; import cn.hutool.crypto.symmetric.SymmetricCrypto; import com.alibaba.druid.pool.DruidDataSource; @@ -62,12 +63,15 @@ public class DruidProps { datasource.setUrl(url); datasource.setUsername(username); - String key = System.getenv(env); -// String key = System.getenv("CCSENS_HT_PROD"); - SymmetricCrypto aes = new SymmetricCrypto(SymmetricAlgorithm.AES, Base64.decode(key)); - //解密为字符串 - String decryptStr = aes.decryptStr(password, CharsetUtil.CHARSET_UTF_8); - datasource.setPassword(decryptStr); + if (StrUtil.isNotEmpty(password)) { + String key = System.getenv(env); + SymmetricCrypto aes = new SymmetricCrypto(SymmetricAlgorithm.AES, Base64.decode(key)); + String decryptStr = aes.decryptStr(password, CharsetUtil.CHARSET_UTF_8); + datasource.setPassword(decryptStr); + } else { + datasource.setPassword(""); + } + datasource.setDriverClassName(driverClassName); //configuration diff --git a/util/src/test/java/com/ccsens/util/KeyTest.java b/util/src/test/java/com/ccsens/util/KeyTest.java index 6c0beff5..e8f4952b 100644 --- a/util/src/test/java/com/ccsens/util/KeyTest.java +++ b/util/src/test/java/com/ccsens/util/KeyTest.java @@ -15,7 +15,7 @@ import org.junit.Test; */ public class KeyTest { /**生成密钥*/ -// @Test + @Test public void test33(){ byte[] key = SecureUtil.generateKey(SymmetricAlgorithm.AES.getValue()).getEncoded(); Console.log(Base64.encode(key)); @@ -23,8 +23,8 @@ public class KeyTest { /**加密*/ // @Test public void test3(){ - String key = "密钥"; - String string = "数据库密码"; + String key = "key"; + String string = "str"; SymmetricCrypto aes = new SymmetricCrypto(SymmetricAlgorithm.AES, Base64.decode(key)); String encryptHex = aes.encryptHex(string); Console.log("{}",encryptHex);