有没有办法通过自动代理配置脚本配置 Eclipse IDE 代理设置?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3841199/
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-10 19:39:31  来源:igfitidea点击:

Is there any way of configuring Eclipse IDE proxy settings via an autoproxy configuration script?

eclipsemavenautoproxy

提问by Vikram

I am behind a firewall which uses autoproxy configuration script. I am able to browse the internet when I enable the autoproxy url in most browsers I use (IE 7, IE 8, FF, Chrome). For your reference to enable autoproxy url on Windows goto: Settings -> Control Panel -> Internet Options -> Connections -> Lan Settings -> (Check) use automatic configuration scripts -> enter Address value as the autoproxy script url.

我在使用 autoproxy 配置脚本的防火墙后面。当我在我使用的大多数浏览器(IE 7、IE 8、FF、Chrome)中启用自动代理 URL 时,我能够浏览互联网。作为在 Windows 上启用自动代理 url 的参考,请转到:设置 -> 控制面板 -> Internet 选项 -> 连接 -> 局域网设置 ->(检查)使用自动配置脚本 -> 输入地址值作为自动代理脚本 url。

The issue I am facing is: I have Eclipse IDE and I want to configure the proxy settings in Eclipse similar to browser settings but I am unable to. I could not find a setting in Eclipse or NetBeans 6.9.1 or IntelliJ Idea to solve this issue.

我面临的问题是:我有 Eclipse IDE,我想在 Eclipse 中配置类似于浏览器设置的代理设置,但我不能。我在 Eclipse 或 NetBeans 6.9.1 或 IntelliJ Idea 中找不到解决此问题的设置。

I am using Maven2 integrated with these IDEs and no local repositories set up yet. Maven2 tries to install jars by downloading them from Internet but it cannot due to the proxy setting. I can manually download these libraries from Maven2 repositories and have an internal repository hosted using Artifactory or Nexus but I would like to know if there is any way I can do it from IDE itself...

我正在使用与这些 IDE 集成的 Maven2,但尚未设置本地存储库。Maven2 尝试通过从 Internet 下载 jars 来安装它们,但由于代理设置而无法安装。我可以从 Maven2 存储库手动下载这些库,并使用 Artifactory 或 Nexus 托管一个内部存储库,但我想知道是否有任何方法可以从 IDE 本身执行此操作...

Thanks for your feedback. Please let me know if you have any questions.

感谢您的反馈意见。请让我知道,如果你有任何问题。

回答by Mykel Alvis

Here is what I do. All of these instructions are based on my minimal experiences with working PACs, so YMMV.

这就是我所做的。所有这些说明都基于我对工作 PAC 的最少经验,所以 YMMV。

Download your pac file via your pac URL. It's plain text and should be easy to open in a text editor.

通过您的 pac URL 下载您的 pac 文件。它是纯文本,应该很容易在文本编辑器中打开。

Near the bottom, there's probably a section that says something like: return "PROXY w.x.y.z:a" where "w.x.y.z" is an ip address or username and "a" is a port number.

在底部附近,可能有一个部分这样说: return "PROXY wxyz:a" 其中 "wxyz" 是 IP 地址或用户名,而 "a" 是端口号。

Write these down.

把这些写下来。

In a recent version of eclipse :

在最新版本的 eclipse 中:

  • Go to Window -> Preferences -> General -> Network Connections=
  • Change the provider to "Manual"
  • Select the "HTTP" line and click the edit button
  • Add the IP address and port number above to the http line
  • If you have to authenticate to use the proxy,
    • select "Requires Authentication"
    • type in your username. Note that if your authentication is on a Windows domain, you might have to prepend the domain name and a backslash (\) like: MYDOMAIN\MYUSERID
    • Type in your password
  • Click OK
  • Click Apply
  • Click OK
  • 转到窗口 -> 首选项 -> 常规 -> 网络连接=
  • 将提供程序更改为“手动”
  • 选择“HTTP”行并单击编辑按钮
  • 将上面的IP地址和端口号添加到http行
  • 如果您必须进行身份验证才能使用代理,
    • 选择“需要身份验证”
    • 输入您的用户名。请注意,如果您的身份验证在 Windows 域中,您可能需要在域名和反斜杠 (\) 前加上:MYDOMAIN\MYUSERID
    • 输入您的密码
  • 单击确定
  • 点击应用
  • 单击确定

At this point, you should be able to browse using the internal web browser (at least on http URLs).

此时,您应该能够使用内部 Web 浏览器进行浏览(至少在 http URL 上)。

Good luck.

祝你好运。

Edit: Just so you know, it's WAY easier to use Nexus, one set of <mirror>tags and a single proxy setup (inside Nexus) to manage the proxy issues of Maven inside a firewall.

编辑:正如您所知,使用Nexus、一组<mirror>标签和单个代理设置(在 Nexus 内)来管理防火墙内 Maven 的代理问题要容易得多。

回答by Zabettina

In the file: $your_eclipse_installation\configuration.settings\org.eclipse.core.net.prefs

在文件中:$your_eclipse_installation\configuration.settings\org.eclipse.core.net.prefs

you need the option: systemProxiesEnabled=true

你需要这个选项:systemProxiesEnabled=true

You can set it also by the Eclipse GUI: Go to Window -> Preferences -> General -> Network Connections Change the provider to "Native"

您也可以通过 Eclipse GUI 设置它:转到 Window -> Preferences -> General -> Network Connections 将提供程序更改为“Native”

The first way is working even if your Eclipse is broken due to wrong configuration attempts.

即使您的 Eclipse 由于错误的配置尝试而损坏,第一种方法也能正常工作。

回答by Saket Yadav

Download proxy script and check last line for return statement Proxy IP and Port.
Add this IP and Port using these step.

   1.  Windows -->Preferences-->General -->Network Connection
   2. Select Active Provider : Manual
   3.  Proxy entries select HTTP--> Click on Edit button
   4.  Then add Host as a proxy IP and port left Required Authentication blank.
   5.  Restart eclipse
   6.  Now Eclipse Marketplace... working.

回答by Sunil

Download whatever configuration script that your browser is using.

下载浏览器正在使用的任何配置脚本。

the script would have various host:port configuration. based on the domain you want to connect , one of the host:port is selected by the borwser.

该脚本将具有各种主机:端口配置。根据您要连接的域,浏览器选择主机:端口之一。

in the eclipse network setting you can try to put on of the host ports and see if that works.

在 eclipse 网络设置中,您可以尝试打开主机端口,看看是否有效。

worked for me.

对我来说有效。

the config script looks like,

配置脚本看起来像,

if (isPlainHostName(host))
    return "DIRECT";
else if (dnsDomainIs(host, "<***sample host name *******>"))
    return "PROXY ***some ip*****; DIRECT";
else if (dnsDomainIs(host, "address.com")
        || dnsDomainIs(host, "adress2..com")
        || dnsDomainIs(host, "address3.com")
        || dnsDomainIs(host, "address4.com")        
    return "PROXY <***some proxyhost****>:8080";

you would need to look for the host port in the return statement.

您需要在返回语句中查找主机端口。

回答by Ladlestein

Well there's the Network Connections preference page; you can add proxies there. I don't know much about it; I don't know if the Maven integration plugins will use the proxies defined there.

嗯,有网络连接首选项页面;你可以在那里添加代理。我对此知之甚少;我不知道 Maven 集成插件是否会使用那里定义的代理。

You can find it at Window...Preferences, then General...Network Connections.

您可以在 Window...Preferences,然后是 General...Network Connections 找到它。

回答by shreedevi

In Netbeans, we can use Tools->Options-> General Tab - > Under proxy settings, select Use system proxy settings.

在Netbeans中,我们可以使用Tools->Options->General Tab->proxy settings下,选择Use system proxy settings。

This way, it uses the proxy settings provided in Settings -> Control Panel -> Internet Options -> Connections -> Lan Settings -> use automatic configuration scripts.

这样,它使用设置 -> 控制面板 -> Internet 选项 -> 连接 -> 局域网设置 -> 使用自动配置脚本中提供的代理设置。

If you are using maven, make sure the proxy settings are not provided there, so that it uses Netbeans settings provided above for proxy.

如果您使用的是 maven,请确保此处未提供代理设置,以便它使用上面提供的 Netbeans 设置进行代理。

Hope this helps.

希望这可以帮助。

Shreedevi

什里德维