安装 EoLinker_4.0 开源版

安装 EoLinker_4.0 开源版

下载

这个链接的资源是百度的别人

https://gitee.com/yaobuyang/eo-linker-ams-lite-java

为了防止以后找不到这个了,我自己上传到百度网盘了;别人的代码有可能会有更新,所以上面链接能用,还是建议下载上面链接中的代码

https://pan.baidu.com/s/11rY_ZIqyOYt3A-B7TPqIZw
提取码: krhq

环境

jdk1.8+
mysql5.8+

数据库

新建数据库:eolinker_os

我用的连接工具为 SQLyog
在这里插入图片描述
在这里插入图片描述

新建表

右键,导入—>执行SQL脚本
在这里插入图片描述
在database文件夹中找到sql文件,然后点击执行。
在这里插入图片描述

执行完成;数据库中又这些表,就是成功了
在这里插入图片描述

部署到Linux

在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中运行

③ api测试报错 415
解决办法

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中运行

④ api测试 响应body出现中文乱码
解决办法

Poxy类中
找到代码:

testResult.put("body", body);

替换为

testResult.put("body", new String(body.getBytes("ISO-8859-1"),"UTF-8"));

更改好后maven打包,然后替换到Linux中运行

我这边更改后的Poxy类代码
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<String, String> params= new LinkedMultiValueMap<String, String>();
//			 HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<MultiValueMap<String, String>>(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

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值