问候,我想在运行时为我的应用程序设置一个新代理,是因为我需要访问两个服务而遇到问题,首先我需要从服务中获取数据并在使用这些服务之后用于访问其他服务的数据。
我有这个:
System.getProperties.setProperty().put("http.proxySet", "true");
System.getProperties.setProperty().put("http.proxyHost", "hostname");
System.getProperties.setProperty().put("http.proxyPort", "port");
System.getProperties.setProperty().put("http.proxyUser", "user");
System.getProperties.setProperty().put("http.proxyPassword", "pass");
写完新代理后:
System.getProperties.setProperty().put("http.proxySet", "true");
System.getProperties.setProperty().put("http.proxyHost", "hostname2");
System.getProperties.setProperty().put("http.proxyPort", "port2");
System.getProperties.setProperty().put("http.proxyUser", "user2");
System.getProperties.setProperty().put("http.proxyPassword", "pass2");
当我尝试再次更改代理时,第一个配置仍然存在。提前谢谢。