这个链接的资源是百度的别人
https://gitee.com/yaobuyang/eo-linker-ams-lite-java
为了防止以后找不到这个了,我自己上传到百度网盘了;别人的代码有可能会有更新,所以上面链接能用,还是建议下载上面链接中的代码
https://pan.baidu.com/s/11rY_ZIqyOYt3A-B7TPqIZw
提取码: krhq
jdk1.8+
mysql5.8+
右键,导入—>执行SQL脚本
在database文件夹中找到sql文件,然后点击执行。
在linux上 cd 到项目目录
新建eolinker文件夹(看自己需要)
mkdir eolinker
上传安装,压缩包目录在下图,将压缩包上传到linux的eolinker目录下
unzip eolinker_os_release_4_0.zip
打开解压的文件夹,进入config文件夹,编辑setting.properties文件
vi setting.properties
修改端口号,dbUser和dbPassword填入连接数据库的账户名和密码,dbUrl填入自己的数据库连接地址
保存,退出
启动jar包
nohup java -jar eolinker_os-4.0.jar &
http://jar所在IP地址:端口号/eolinker_os/index.html
查看Linux防火墙对应的端口有没有打开
firewall-cmd --query-port=端口号/tcp
ps:yes 表示开启;no 表示未开启
开启端口
firewall-cmd --zone=public --add-port=端口号/tcp --permanent
firewall-cmd --reload
打开下载文件中的源码
在上图文件夹中的文件更改
将这些更换成自己数据库的连接、用户、密码、驱动;还有Linux访问项目的端口号
更改好后maven打包,然后替换到Linux中运行
在Poxy类中
找到代码:
requestHeaders.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
把它注释掉;
-------------------------------------------------------------分割线--------------------------------------------------------------
找到代码:
HttpStatus statusCode = responseEntity.getStatusCode();
替换为:
int statusCode = responseEntity.getStatusCodeValue();
-------------------------------------------------------------分割线--------------------------------------------------------------
找到代码:
result.put("testHttpCode", new Integer(statusCode.toString()));
替换为:
result.put("testHttpCode", statusCode);
-------------------------------------------------------------分割线--------------------------------------------------------------
集合
MultiValueMap
替换为
Map
更改好后maven打包,然后替换到Linux中运行
在Poxy类中
找到代码:
testResult.put("body", body);
替换为
testResult.put("body", new String(body.getBytes("ISO-8859-1"),"UTF-8"));
更改好后maven打包,然后替换到Linux中运行
public class Proxy {
//请求远程服务
public Map<String, Object> proxyToDesURL(String method, String completeURL,
List<Map<String, String>> headerList, List<Map<String, String>> paramList)
{
// TODO Auto-generated method stub
Map<String, Object> result = new HashMap<String, Object>();
Date nowTime = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String testTime = dateFormat.format(nowTime);
long startTime = 0;
long endTime = 0;
long deny = 0;
try {
SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
RestTemplate restTemplate = new RestTemplate(requestFactory);
HttpHeaders requestHeaders = new HttpHeaders();
// MultiValueMap params= new LinkedMultiValueMap();
// HttpEntity> requestEntity = new HttpEntity>(params, requestHeaders);
Map<String, String> params= new LinkedMap<String, String>();
HttpEntity<Map<String, String>> requestEntity = new HttpEntity<Map<String, String>>(params, requestHeaders);
if(headerList != null && !headerList.isEmpty()) {
for(Map<String, String> header : headerList) {
requestHeaders.add(header.get("name"), header.get("value"));
}
}
if(!method.equals("GET")) {
if(paramList != null && !paramList.isEmpty()) {
for(Map<String, String> param : paramList) {
// params.add(param.get("key"), param.get("value"));
params.put(param.get("key"), param.get("value"));
}
}
// requestHeaders.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
requestEntity = new HttpEntity<Map<String, String>>(params, requestHeaders);
}
HttpMethod requestType = HttpMethod.GET;
switch (method) {
case "GET":
requestType = HttpMethod.GET;
break;
case "POST":
requestType = HttpMethod.POST;
break;
case "PUT":
requestType = HttpMethod.PUT;
break;
case "DELETE":
requestType = HttpMethod.DELETE;
break;
case "HEAD":
requestType = HttpMethod.HEAD;
break;
case "OPTIONS":
requestType = HttpMethod.OPTIONS;
break;
default:
break;
}
Map<String, Object> testResult = new HashMap<String, Object>();
startTime = System.currentTimeMillis();
ResponseEntity<String> responseEntity = restTemplate.exchange(completeURL, requestType, requestEntity, String.class);
endTime = System.currentTimeMillis();
deny = endTime - startTime;
// HttpStatus statusCode = responseEntity.getStatusCode();
int statusCode = responseEntity.getStatusCodeValue();
HttpHeaders headers = responseEntity.getHeaders();
List<Map<String, String>> responseHeaders = new ArrayList<Map<String, String>>();
for(String key : headers.keySet()) {
Map<String, String> responseHeader = new HashMap<String, String>();
responseHeader.put("key", key);
responseHeader.put("value", StringUtils.join(headers.get(key).toArray()));
responseHeaders.add(responseHeader);
}
String body = responseEntity.getBody();
testResult.put("headers", responseHeaders);
// testResult.put("body", body);
testResult.put("body", new String(body.getBytes("ISO-8859-1"),"UTF-8"));
// System.out.println("================== bodybodybodybodybody ISO-8859-1" + new String(body.getBytes("ISO-8859-1"),"UTF-8"));
result.put("testTime", testTime);
// result.put("testHttpCode", new Integer(statusCode.toString()));
result.put("testHttpCode", statusCode);
result.put("testResult", testResult);
result.put("testDeny", deny);
} catch (Exception e) {
// TODO: handle exception
endTime = System.currentTimeMillis();
deny = endTime - startTime;
Map<String, Object> testResult = new HashMap<String, Object>();
testResult.put("headers", null);
testResult.put("body", e.getMessage());
result.put("testTime", testTime);
result.put("testHttpCode", 500);
result.put("testResult", testResult);
result.put("testDeny", deny);
}
return result;
}
}
参考博客:
https://blog.csdn.net/weixin_45553582/article/details/108166799
https://blog.csdn.net/weixin_44718708/article/details/112000304