Commit ca59c24b6009049975f3ee4de84db5106c32a242

Authored by suweicheng
1 parent a619f762

开发梳理;

@@ -14,6 +14,8 @@ @@ -14,6 +14,8 @@
14 14
15 <properties> 15 <properties>
16 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 16 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  17 + <maven-compiler-plugin.version>3.3</maven-compiler-plugin.version>
  18 + <jdk.version>1.8</jdk.version>
17 </properties> 19 </properties>
18 20
19 <dependencies> 21 <dependencies>
@@ -120,6 +122,18 @@ @@ -120,6 +122,18 @@
120 <plugins> 122 <plugins>
121 <plugin> 123 <plugin>
122 <groupId>org.apache.maven.plugins</groupId> 124 <groupId>org.apache.maven.plugins</groupId>
  125 + <artifactId>maven-compiler-plugin</artifactId>
  126 + <version>${maven-compiler-plugin.version}</version>
  127 + <configuration>
  128 + <encoding>utf-8</encoding>
  129 + <source>${jdk.version}</source>
  130 + <target>${jdk.version}</target>
  131 + <meminitial>128m</meminitial>
  132 + <maxmem>512m</maxmem>
  133 + </configuration>
  134 + </plugin>
  135 + <plugin>
  136 + <groupId>org.apache.maven.plugins</groupId>
123 <artifactId>maven-surefire-plugin</artifactId> 137 <artifactId>maven-surefire-plugin</artifactId>
124 <version>2.7.1</version> 138 <version>2.7.1</version>
125 <configuration> 139 <configuration>
src/main/java/com/essa/framework/ConfigProperties.java
@@ -15,6 +15,15 @@ public class ConfigProperties { @@ -15,6 +15,15 @@ public class ConfigProperties {
15 private String serverURL; 15 private String serverURL;
16 private String buyerURL; 16 private String buyerURL;
17 17
  18 + // 数据库驱动名字
  19 + private String jdbcName = null;
  20 + // 数据库协议地址
  21 + private String dbUrl = null;
  22 + // 数据库用户名
  23 + private String dbUser = null;
  24 + // 数据库密码
  25 + private String dbPassword = null;
  26 +
18 private ConfigProperties() { 27 private ConfigProperties() {
19 28
20 } 29 }
@@ -32,6 +41,10 @@ public class ConfigProperties { @@ -32,6 +41,10 @@ public class ConfigProperties {
32 configProperties.setBrowserName(p.getProperty("browserName"));//使用jframe要注释 41 configProperties.setBrowserName(p.getProperty("browserName"));//使用jframe要注释
33 configProperties.setBuyerURL(p.getProperty("buyerURL")); 42 configProperties.setBuyerURL(p.getProperty("buyerURL"));
34 configProperties.setServerURL(p.getProperty("serverURL")); 43 configProperties.setServerURL(p.getProperty("serverURL"));
  44 + configProperties.setJdbcName(p.getProperty("jdbc.driver"));
  45 + configProperties.setDbUrl(p.getProperty("jdbc.url"));
  46 + configProperties.setDbUser(p.getProperty("jdbc.user"));
  47 + configProperties.setDbPassword(p.getProperty("jdbc.pwd"));
35 configPropertiesMap.put(envEnum.getCode(),configProperties); 48 configPropertiesMap.put(envEnum.getCode(),configProperties);
36 ips.close(); 49 ips.close();
37 } catch (IOException e) { 50 } catch (IOException e) {
@@ -67,4 +80,36 @@ public class ConfigProperties { @@ -67,4 +80,36 @@ public class ConfigProperties {
67 public void setBuyerURL(String buyerURL) { 80 public void setBuyerURL(String buyerURL) {
68 this.buyerURL = buyerURL; 81 this.buyerURL = buyerURL;
69 } 82 }
  83 +
  84 + public String getJdbcName() {
  85 + return jdbcName;
  86 + }
  87 +
  88 + public void setJdbcName(String jdbcName) {
  89 + this.jdbcName = jdbcName;
  90 + }
  91 +
  92 + public String getDbUrl() {
  93 + return dbUrl;
  94 + }
  95 +
  96 + public void setDbUrl(String dbUrl) {
  97 + this.dbUrl = dbUrl;
  98 + }
  99 +
  100 + public String getDbUser() {
  101 + return dbUser;
  102 + }
  103 +
  104 + public void setDbUser(String dbUser) {
  105 + this.dbUser = dbUser;
  106 + }
  107 +
  108 + public String getDbPassword() {
  109 + return dbPassword;
  110 + }
  111 +
  112 + public void setDbPassword(String dbPassword) {
  113 + this.dbPassword = dbPassword;
  114 + }
70 } 115 }
src/main/java/com/essa/framework/DButil.java
1 package com.essa.framework; 1 package com.essa.framework;
2 2
  3 +import com.mysql.cj.api.jdbc.Statement;
  4 +import com.mysql.cj.jdbc.CallableStatement;
  5 +import com.mysql.cj.jdbc.PreparedStatement;
  6 +
3 import java.sql.Connection; 7 import java.sql.Connection;
4 import java.sql.DriverManager; 8 import java.sql.DriverManager;
5 import java.sql.ResultSet; 9 import java.sql.ResultSet;
6 import java.sql.SQLException; 10 import java.sql.SQLException;
7 11
8 -import com.mysql.cj.api.jdbc.Statement;  
9 -import com.mysql.cj.jdbc.CallableStatement;  
10 -import com.mysql.cj.jdbc.PreparedStatement;  
11 -  
12 public class DButil { 12 public class DButil {
13 - // 数据库驱动名字 13 + /*// 数据库驱动名字
14 private static String jdbcName = null; 14 private static String jdbcName = null;
15 // 数据库协议地址 15 // 数据库协议地址
16 private static String dbUrl = null; 16 private static String dbUrl = null;
@@ -18,10 +18,20 @@ public class DButil { @@ -18,10 +18,20 @@ public class DButil {
18 private static String dbUser = null; 18 private static String dbUser = null;
19 // 数据库密码 19 // 数据库密码
20 private static String dbPassword = null; 20 private static String dbPassword = null;
21 - 21 +*/
22 public static Connection getCon() { 22 public static Connection getCon() {
  23 +
23 Connection conn = null; 24 Connection conn = null;
24 - if ("SIT".equals(Model.getEnv())) { 25 + try {
  26 + EnvEnum envEnum = EnvEnum.fromCode(Model.getEnv());
  27 + ConfigProperties dbConfig = ConfigProperties.getConfig(envEnum);
  28 + Class.forName(dbConfig.getJdbcName());
  29 + conn = DriverManager.getConnection(dbConfig.getDbUrl(),dbConfig.getDbUser(), dbConfig.getDbPassword());
  30 + } catch (Exception e) {
  31 + e.printStackTrace();
  32 + }
  33 + return conn;
  34 + /*if ("SIT".equals(Model.getEnv())) {
25 try { 35 try {
26 jdbcName = DBInfo.getSitJdbcName(); 36 jdbcName = DBInfo.getSitJdbcName();
27 dbUrl = DBInfo.getSitSqlUrl(); 37 dbUrl = DBInfo.getSitSqlUrl();
@@ -70,7 +80,7 @@ public class DButil { @@ -70,7 +80,7 @@ public class DButil {
70 e.printStackTrace(); 80 e.printStackTrace();
71 } 81 }
72 } 82 }
73 - return null; 83 + return null;*/
74 } 84 }
75 85
76 /** 86 /**
src/main/resources/conf/config_dit.properties
@@ -5,3 +5,7 @@ browserName=Chrome @@ -5,3 +5,7 @@ browserName=Chrome
5 serverURL=http://bpms.dit.gz.essa 5 serverURL=http://bpms.dit.gz.essa
6 buyerURL=http://en.portaldit.cn 6 buyerURL=http://en.portaldit.cn
7 7
  8 +jdbc.driver=com.mysql.cj.jdbc.Driver
  9 +jdbc.url=jdbc:mysql://192.168.1.202:3307/bpms
  10 +jdbc.user=root
  11 +jdbc.pwd=redhat
8 \ No newline at end of file 12 \ No newline at end of file
src/main/resources/conf/config_hotfix.properties
@@ -5,3 +5,9 @@ browserName=Chrome @@ -5,3 +5,9 @@ browserName=Chrome
5 serverURL=http://bpms.hotfix.gz.essa 5 serverURL=http://bpms.hotfix.gz.essa
6 buyerURL=http://en.portalhotfix.cn 6 buyerURL=http://en.portalhotfix.cn
7 7
  8 +
  9 +jdbc.driver=com.mysql.cj.jdbc.Driver
  10 +jdbc.url=jdbc:mysql://192.168.1.19:3321/bpms
  11 +jdbc.user=essa_hotfix
  12 +jdbc.pwd=essa^_hotfix^D<K123
  13 +
src/main/resources/conf/config_sit.properties
@@ -5,3 +5,7 @@ browserName=Chrome @@ -5,3 +5,7 @@ browserName=Chrome
5 serverURL=http://bpms.sit.gz.essa 5 serverURL=http://bpms.sit.gz.essa
6 buyerURL=http://en.portalsit.cn 6 buyerURL=http://en.portalsit.cn
7 7
  8 +jdbc.driver=com.mysql.cj.jdbc.Driver
  9 +jdbc.url=jdbc:mysql://192.168.1.247:3307/bpms
  10 +jdbc.user=root
  11 +jdbc.pwd=redhat
8 \ No newline at end of file 12 \ No newline at end of file
src/main/resources/conf/config_uat.properties
@@ -5,3 +5,7 @@ browserName=Chrome @@ -5,3 +5,7 @@ browserName=Chrome
5 serverURL=http://bpms.spstoys.com:7291 5 serverURL=http://bpms.spstoys.com:7291
6 buyerURL=http://en.spstoys.com:889 6 buyerURL=http://en.spstoys.com:889
7 7
  8 +jdbc.driver=com.mysql.cj.jdbc.Driver
  9 +jdbc.url=jdbc:mysql://112.74.135.97:3325/bpms
  10 +jdbc.user=essa_uat
  11 +jdbc.pwd=lXI!RqH6thvmMNNh
8 \ No newline at end of file 12 \ No newline at end of file
src/main/resources/config.properties deleted
@@ -1,16 +0,0 @@ @@ -1,16 +0,0 @@
1 -#browserName=FireFox  
2 -#browserName=IE  
3 -browserName=Chrome  
4 -  
5 -SIT=http://bpms.sit.gz.essa  
6 -BSIT=http://en.portalsit.cn  
7 -  
8 -HOTFIX=http://bpms.hotfix.gz.essa  
9 -BHOTFIX=http://en.portalhotfix.cn  
10 -  
11 -UAT=http://bpms.spstoys.com:7291  
12 -BUAT=http://en.spstoys.com:889  
13 -  
14 -DIT=http://bpms.dit.gz.essa  
15 -BDIT=http://en.portaldit.cn  
16 -