eclipse 如何在eclipse中设置http代理?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5291871/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 15:58:33  来源:igfitidea点击:

How can I set the http proxy in eclipse?

javaeclipsehttpproxy

提问by Joeblackdev

I have code that needs to make an outbound http connection. However, I am behind a proxy. I have seen examples of how to set the proxy parameters, but none of which allow me to specify my username and password.

我有需要建立出站 http 连接的代码。但是,我支持代理。我看过有关如何设置代理参数的示例,但没有一个示例允许我指定我的用户名和密码。

Has anyone got an example to help me out?

有没有人有例子可以帮助我?

回答by Konstantin Komissarchik

Here is a reference on configuration proxy information for any Java app. If you are running your app from Eclipse, you will want to set these in your launch configuration.

这是有关任何 Java 应用程序的配置代理信息的参考。如果您从 Eclipse 运行您的应用程序,您将需要在启动配置中设置这些。

http://download.oracle.com/javase/6/docs/technotes/guides/net/proxies.html

http://download.oracle.com/javase/6/docs/technotes/guides/net/proxies.html

回答by Andrew White

  1. [Windows] -> [Preferences] -> [General] -> [Network Connections]
  2. Set Active Provider to "Manual"
  3. Select protocol (HTTP)
  4. Click Edit
  5. Click "Requires Authentication"
  6. Provide creds
  1. [Windows] -> [首选项] -> [常规] -> [网络连接]
  2. 将 Active Provider 设置为“手动”
  3. 选择协议 (HTTP)
  4. 点击编辑
  5. 单击“需要身份验证”
  6. 提供信用

回答by MeBigFatGuy

Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("30.40.50.60", 8080));
URL url = new URL("http://www.somewebsite.com");
HttpURLConnection uc = (HttpURLConnection)url.openConnection(proxy);

回答by bindu

You can find this under Run->Run Configurations or Run->Debug Configurations, under the “Target” tab. You're looking for the “Additional Emulator Command Line Options” box. In my case, the full string I used was -http-proxy http://username:[email protected]:3128where username is my proxy login, password is my proxy password, 10.0.0.1 is my proxy IP address, 3128 is the port.

您可以在“目标”选项卡下的“运行”->“运行配置”或“运行->调试配置”下找到它。您正在寻找“其他仿真器命令行选项”框。就我而言,我使用的完整字符串是 -http-proxy http://username:[email protected]:3128其中用户名是我的代理登录名,密码是我的代理密码,10.0.0.1 是我的代理 IP 地址,3128是港口。

emulator settings from within the emulator. I have no idea why this is necessary but it didn't work without this change. Once you launch the emulator, go to Settings->Wireless & Networks->Mobile Networks->Access Point Names->TelKila and set “Proxy” and “Port” to match the settings above

模拟器内的模拟器设置。我不知道为什么这是必要的,但如果没有这个改变它就不起作用。启动模拟器后,转到 Settings->Wireless & Networks->Mobile Networks->Access Point Names->TelKila 并设置“Proxy”和“Port”以匹配上述设置