6

我正在使用 Rest-Assured 来测试我的 Rest API。网络服务似乎运行正常,因为正在运行

    curl -u "admin:admin" http://localhost:8888/users/

我将我的用户作为 json。

然后,当尝试使用 Rest-Assured 进行简单请求时

 RestAssured.authentication = basic("admin", "admin");

  expect().statusCode(200).when().get("http://localhost:8888/users/");

给我输出

    Exception in thread "main" org.apache.http.conn.HttpHostConnectException: Connection to http://localhost:8888 refused
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:158)
…

这会是什么?

4

1 回答 1

5

解决了。从 更改localhost127.0.0.1并且它起作用了。cURL/浏览器都与 localhost 一起工作有点奇怪。猜猜这可能是一个路由问题。

于 2012-05-08T22:05:52.700 回答