String rabbitmqHost = "192.168.0.100"; String rabbitmqPort = "15672"; String userName = "xxxx"; String password = "password"; String url = String.format("http://%s:%s/api/overview",rabbitmqHost,rabbitmqPort); BASE64Encoder base64Encoder = new BASE64Encoder(); String base64Str = String.format("%s:%s",userName,password); String base64Val = base64Encoder.encode(base64Str.getBytes()); Map<String,String> headerMap = new HashMap<>(); String authHash = String.format("Basic %s",base64Val ); headerMap.put("authorization",authHash);
authorization添加到http的请求头,
然后get请求url,
即可拿到数据