Commit ca59c24b6009049975f3ee4de84db5106c32a242
1 parent
a619f762
开发梳理;
Showing
8 changed files
with
95 additions
and
24 deletions
Show diff stats
pom.xml
... | ... | @@ -14,6 +14,8 @@ |
14 | 14 | |
15 | 15 | <properties> |
16 | 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 | 19 | </properties> |
18 | 20 | |
19 | 21 | <dependencies> |
... | ... | @@ -120,6 +122,18 @@ |
120 | 122 | <plugins> |
121 | 123 | <plugin> |
122 | 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 | 137 | <artifactId>maven-surefire-plugin</artifactId> |
124 | 138 | <version>2.7.1</version> |
125 | 139 | <configuration> | ... | ... |
src/main/java/com/essa/framework/ConfigProperties.java
... | ... | @@ -15,6 +15,15 @@ public class ConfigProperties { |
15 | 15 | private String serverURL; |
16 | 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 | 27 | private ConfigProperties() { |
19 | 28 | |
20 | 29 | } |
... | ... | @@ -32,6 +41,10 @@ public class ConfigProperties { |
32 | 41 | configProperties.setBrowserName(p.getProperty("browserName"));//使用jframe要注释 |
33 | 42 | configProperties.setBuyerURL(p.getProperty("buyerURL")); |
34 | 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 | 48 | configPropertiesMap.put(envEnum.getCode(),configProperties); |
36 | 49 | ips.close(); |
37 | 50 | } catch (IOException e) { |
... | ... | @@ -67,4 +80,36 @@ public class ConfigProperties { |
67 | 80 | public void setBuyerURL(String buyerURL) { |
68 | 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 | 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 | 7 | import java.sql.Connection; |
4 | 8 | import java.sql.DriverManager; |
5 | 9 | import java.sql.ResultSet; |
6 | 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 | 12 | public class DButil { |
13 | - // 数据库驱动名字 | |
13 | + /*// 数据库驱动名字 | |
14 | 14 | private static String jdbcName = null; |
15 | 15 | // 数据库协议地址 |
16 | 16 | private static String dbUrl = null; |
... | ... | @@ -18,10 +18,20 @@ public class DButil { |
18 | 18 | private static String dbUser = null; |
19 | 19 | // 数据库密码 |
20 | 20 | private static String dbPassword = null; |
21 | - | |
21 | +*/ | |
22 | 22 | public static Connection getCon() { |
23 | + | |
23 | 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 | 35 | try { |
26 | 36 | jdbcName = DBInfo.getSitJdbcName(); |
27 | 37 | dbUrl = DBInfo.getSitSqlUrl(); |
... | ... | @@ -70,7 +80,7 @@ public class DButil { |
70 | 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
src/main/resources/conf/config_hotfix.properties
src/main/resources/conf/config_sit.properties
src/main/resources/conf/config_uat.properties
... | ... | @@ -5,3 +5,7 @@ browserName=Chrome |
5 | 5 | serverURL=http://bpms.spstoys.com:7291 |
6 | 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 | 12 | \ No newline at end of file | ... | ... |
src/main/resources/config.properties deleted
... | ... | @@ -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 | - |