我正在尝试建立url但出现异常

时间:2019-01-02 13:42:35

标签: java http spring-boot

HttpUrl url = new HttpUrl.Builder().scheme("http")
                .host("localhost:8080") // here I'm getting error
                .addPathSegment("organization").build();

这是错误=> java.lang.IllegalArgumentException:意外的主机:localhost:8080

1 个答案:

答案 0 :(得分:3)

是:

HttpUrl url = new HttpUrl.Builder().scheme("http")
            .host("localhost")
            .port(8080)
            .addPathSegment("organization").build();