andyxrl

andyxrl 查看完整档案

杭州编辑  |  填写毕业院校  |  填写所在公司/组织 segmentfault.com/u/andyxrl 编辑
编辑

dsadsa

个人动态

andyxrl 关注了专栏 · 2018-11-19

SpringCloud

SpringCloud 自学教程

关注 36

andyxrl 关注了用户 · 2018-09-04

一只袜子 @yizhiwazi

关注 16

andyxrl 关注了问题 · 2017-10-11

解决java报错Communications link failure 该如何解决?

  1. 就是普通的查询mysql数据库的代码:

  2. 错误栈如下:

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
    at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074)
    at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2209)
    at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:776)
    at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
    at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:352)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:284)
    at java.sql.DriverManager.getConnection(DriverManager.java:571)
    at java.sql.DriverManager.getConnection(DriverManager.java:215)
    at testHttpConnection.util.DBUtil.getConn(DBUtil.java:26)
    at testHttpConnection.TestMysql.main(TestMysql.java:23)
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
    at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074)
    at com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:675)
    at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1078)
    at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2137)
    ... 13 more
Caused by: java.net.SocketException: Permission denied: recv failed
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:152)
    at java.net.SocketInputStream.read(SocketInputStream.java:122)
    at com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:113)
    at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:160)
    at com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:188)
    at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2494)
    at com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:599)
    ... 15 more

关注 5 回答 2

andyxrl 赞了文章 · 2017-07-14

不可不知的centos7 firewalld 防火墙的使用

centos7 firewalld 防火墙的使用

FirewallD is not running

是你的防火墙还没开。 可以执行 systemctl start firewalld 开启防火墙。

相关命令 CentOS 7 上systemctl 的用法

http://www.linuxidc.com/Linux/2014-11/109236.htm

systemctl status firewalld

clipboard.png

firewalld使用简介

http://www.centoscn.com/CentOS/help/2015/0208/4667.html

Centos7 开放端口

Centos升级到7之后,发现无法使用iptables控制Linuxs的端口,google之后发现Centos 7使用firewalld代替了原来的iptables。下面记录如何使用firewalld开放Linux端口:

开启端口

firewall-cmd --zone=public --add-port=80/tcp --permanent

命令含义:

--zone #作用域

--add-port=80/tcp #添加端口,格式为:端口/通讯协议

--permanent #永久生效,没有此参数重启后失效

重启防火墙

firewall-cmd --reload

详细信息可以参考以下资料:

http://stackoverflow.com/questions/24729024/centos-7-open-firewall-port

https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Security_Guide/sec-Using_Firewalls.html

查看原文

赞 5 收藏 19 评论 1

andyxrl 回答了问题 · 2017-07-14

解决使用Vue的axios vue-resource跨域不成功 但原生xhr就可以

图片描述

nginx 如此设置就可以访问,亲测有用。

关注 12 回答 4

andyxrl 关注了问题 · 2017-07-13

能否讲一下vue.js中的ajax?

能否讲一下vue.js中的ajax?

关注 29 回答 3

andyxrl 关注了标签 · 2017-07-09

antd

ant-design ,react 框架

关注 965

andyxrl 关注了用户 · 2017-07-07

mercyblitz @mercyblitz

小马哥,Java 劝退师,《Spring Boot 编程思想》作者,Apache 和 Spring Cloud 等知名开源架构成员,点击查看详情。(交流QQ群:719291662

最新发布:
Spring Boot 2.0深度实践之核心技术篇
Java 微服务实践系列课堂
「一入 Java 深似海 」系列课程

关注 2871

andyxrl 提出了问题 · 2016-11-15

java httpClient wsdl 调用失败.求高手看下我代码?

import java.io.IOException;

import org.apache.http.HttpEntity;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
public class TouricoTest {

/**
 * 请求超时
 */
public static final int CONNECT_TIMEOUT=90000;

/**
 * 读取超时
 */
public static final int READ_TIMEOUT=120000;
public static void main(String[] args) {
    String result = "";
    CloseableHttpClient httpclient=null;
    CloseableHttpResponse response=null;
    try{
        String serverStr = "http://demo-hotelws.touricoholidays.com/HotelFlow.svc?wsdl"; //接口请求地址
        httpclient = HttpClients.custom().setDefaultRequestConfig(getRequestConfig(CONNECT_TIMEOUT, READ_TIMEOUT)).build();
        HttpPost httppost = new HttpPost(serverStr);

        String requestParamter = getParamXml();//请求参数
        HttpEntity stringEntry = new StringEntity(requestParamter, "utf-8");
        httppost.setHeader("Content-Type", "text/xml; charset=utf-8");

        String wsRequestStr = "SearchHotelsById";//webservice 请求指定接口方法

        httppost.setHeader("SOAPAction", wsRequestStr);
        httppost.setHeader("Expect", "100-continue");
        httppost.setHeader("Accept-Encoding", "gzip,deflate");
        httppost.setHeader("Connection", "Keep-Alive");
        httppost.setEntity(stringEntry);

        response = httpclient.execute(httppost);

        HttpEntity entity = response.getEntity();

        if (entity != null) {
            int status = response.getStatusLine().getStatusCode();
            if ((status >= 200 && status < 300)) {
                result = EntityUtils.toString(entity);
            } else {
                result=null;
            }
        }
    }
    catch(Exception ex){
        result=null;
        ex.printStackTrace();
    }finally{
        if(null!=response){
            try {
                response.close();
            }catch (IOException e) {
                e.printStackTrace();
            }
        }
        if(null!=httpclient){
            try {
                httpclient.close();
            }catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    //接口响应返回接口
    System.out.println(result);
}

private static RequestConfig getRequestConfig(int connectTimeout,int readTimeout){
    RequestConfig defaultRequestConfig = RequestConfig.custom()
            .setSocketTimeout(connectTimeout)
            .setConnectTimeout(connectTimeout)
            .setConnectionRequestTimeout(readTimeout)
            .build();
    return defaultRequestConfig;
}

private static String getParamXml(){
    StringBuilder sb = new StringBuilder();
    sb.append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:aut=\"http://schemas.tourico.com/webservices/authentication\" xmlns:hot=\"http://tourico.com/webservices/hotelv3\" xmlns:hot1=\"http://schemas.tourico.com/webservices/hotelv3\">");
    sb.append("<soapenv:Header><aut:AuthenticationHeader><aut:LoginName>Tu0906</aut:LoginName><aut:Password>111111</aut:Password><!--Optional:--> <aut:Culture>en_US</aut:Culture><!--Optional:--><aut:Version>5</aut:Version></aut:AuthenticationHeader></soapenv:Header>\n");
    sb.append("<soapenv:Body><hot:SearchHotelsById><hot:request><hot1:HotelIdsInfo><hot1:HotelIdInfo id=\"964\"/></hot1:HotelIdsInfo><hot1:CheckIn>2016-11-19</hot1:CheckIn>");
    sb.append("<hot1:CheckOut>2016-11-21</hot1:CheckOut><hot1:RoomsInformation><hot1:RoomInfo><hot1:AdultNum>4</hot1:AdultNum><hot1:ChildNum>0</hot1:ChildNum>");
    sb.append("<hot1:ChildAges><hot1:ChildAge age=\"0\"/><hot1:ChildAge age=\"0\"/></hot1:ChildAges></hot1:RoomInfo></hot1:RoomsInformation><hot1:MaxPrice>0</hot1:MaxPrice>");
    sb.append("<hot1:StarLevel>0</hot1:StarLevel><hot1:AvailableOnly>1</hot1:AvailableOnly></hot:request><hot:features><hot:Feature name=\"?\" value=\"?\"/></hot:features>");
    sb.append("</hot:SearchHotelsById></soapenv:Body></soapenv:Envelope>");

    return sb.toString();
}

上述是一份完整的wsdl 调用代码. 但是调不通. 请高手帮我诊断一下问题在哪?

关注 1 回答 0

andyxrl 提出了问题 · 2016-10-31

解决maven 如何引用本地jar

我有一个第三方jar 包. 想在maven 项目中引用. 请问各位大牛大牛应该怎么操作?

关注 4 回答 2

认证与成就

  • 获得 7 次点赞
  • 获得 126 枚徽章 获得 6 枚金徽章, 获得 48 枚银徽章, 获得 72 枚铜徽章

擅长技能
编辑

(゚∀゚ )
暂时没有

开源项目 & 著作
编辑

(゚∀゚ )
暂时没有

注册于 2014-04-02
个人主页被 726 人浏览