config moved
为避免冲突讲config.propertiese移入src/main/java/com/foxinmy/weixin4j目录并更新其它相关
This commit is contained in:
parent
0e60f200af
commit
a1a5cd59b3
7
pom.xml
7
pom.xml
@ -35,6 +35,13 @@
|
||||
<exclude>logback.xml</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/java</directory>
|
||||
<includes>
|
||||
<include>**/config.properties</include>
|
||||
<include>**/error.xml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<finalName>weixin4j-sdk</finalName>
|
||||
</build>
|
||||
|
||||
@ -10,6 +10,7 @@ import org.dom4j.io.SAXReader;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.foxinmy.weixin4j.WeixinProxy;
|
||||
import com.foxinmy.weixin4j.msg.ErrorMessage;
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
|
||||
@ -59,12 +60,17 @@ public class Response {
|
||||
JSONObject jsonObj = getAsJson();
|
||||
if (jsonObj.containsKey(ERROR_CODE_KEY)) {
|
||||
SAXReader reader = new SAXReader();
|
||||
Document doc = reader.read(Thread.currentThread().getContextClassLoader().getResourceAsStream("error_code.xml"));
|
||||
Node node = doc.getRootElement().selectSingleNode(String.format("error[@code='%d']", jsonObj.getInteger(ERROR_CODE_KEY)));
|
||||
Document doc = reader.read(WeixinProxy.class
|
||||
.getResourceAsStream("error.xml"));
|
||||
Node node = doc.getRootElement().selectSingleNode(
|
||||
String.format("error[@code='%d']",
|
||||
jsonObj.getInteger(ERROR_CODE_KEY)));
|
||||
if (node != null) {
|
||||
return new ErrorMessage(jsonObj.getInteger(ERROR_CODE_KEY), jsonObj.getString(ERROR_MSG_KEY), node.getStringValue());
|
||||
return new ErrorMessage(jsonObj.getInteger(ERROR_CODE_KEY),
|
||||
jsonObj.getString(ERROR_MSG_KEY), node.getStringValue());
|
||||
}
|
||||
return new ErrorMessage(jsonObj.getInteger(ERROR_CODE_KEY), "unknown error", "未知错误");
|
||||
return new ErrorMessage(jsonObj.getInteger(ERROR_CODE_KEY),
|
||||
"unknown error", "未知错误");
|
||||
}
|
||||
|
||||
return new ErrorMessage(0, "request success", "");
|
||||
|
||||
@ -6,6 +6,8 @@ import java.util.Properties;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.foxinmy.weixin4j.WeixinProxy;
|
||||
|
||||
public class WeixinConfig {
|
||||
public WeixinConfig() {
|
||||
}
|
||||
@ -13,7 +15,8 @@ public class WeixinConfig {
|
||||
private static Properties props = new Properties();
|
||||
static {
|
||||
try {
|
||||
props.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("config.properties"));
|
||||
props.load(WeixinProxy.class
|
||||
.getResourceAsStream("config.properties"));
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
@ -29,7 +32,8 @@ public class WeixinConfig {
|
||||
String sub = null;
|
||||
while (m.find()) {
|
||||
sub = m.group();
|
||||
m.appendReplacement(sb, getValue(sub.substring(1, sub.length() - 1)));
|
||||
m.appendReplacement(sb,
|
||||
getValue(sub.substring(1, sub.length() - 1)));
|
||||
}
|
||||
m.appendTail(sb);
|
||||
return sb.toString();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user