简体   繁体   English

Eclipse Settings.xml中的代理配置

[英]Proxy configuration in Eclipse Settings.xml

"Failure to transfer org.apache.maven.plugins:maven-failsafe-plugin:pom:2.16 from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will 
 not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.maven.plugins:maven-failsafe-
 plugin:pom:2.16 from/to central (http://repo.maven.apache.org/maven2): proxy.example.com"

I am getting the above error in pom tag. 我在pom标签中遇到上述错误。 I searched and found out this is due to proxy settings issue. 我搜索并发现这是由于代理设置问题。 But whatismyip.com shows "no proxy detected". 但是whatismyip.com显示“没有检测到代理”。

Question 1: Still could I be behind proxy? 问题1:我还能支持代理吗? If yes how to get the information about proxy. 如果是,如何获取有关代理的信息。

I learned that users>home>.m2>settings.xml needs to be updated with proxies. 我了解到用户> home> .m2> settings.xml需要使用代理进行更新。 For ex: 例如:

<proxies>
   <proxy>
      <id>example-proxy</id>
      <active>true</active>
      <protocol>http</protocol>
      <username>tomcat</username>
      <password>tomcat</password>
      <host>proxy.example.com</host>
      <port>8008</port>
      <nonProxyHosts>www.google.com|*.example.com</nonProxyHosts>
   </proxy>
</proxies>

Question 2: In this what do I substitute for my case in tag or where can I find information that is specific to myself. 问题2:在这里我可以用标签代替我的案例,或者在哪里可以找到特定于我自己的信息。

Question 3: Is there any correlation between users>home>.m2>settings.xml and eclipse window>preferences>general>network Connections>Active Provider(Manual)>http. 问题3:用户>主页> .m2> settings.xml eclipse窗口>首选项>常规>网络连接>活动提供程序(手动)> http之间是否存在任何关联。 Do I need to update the same information in both places. 我是否需要在两个地方更新相同的信息。

Question 1: Still could I be behind proxy? 问题1:我还能支持代理吗? If yes how to get the information about proxy. 如果是,如何获取有关代理的信息。

Assuming you are using Windows : 假设您使用的是Windows

  1. Trigger Run command: Press Win + R , and type inetcpl.cpl , OK. Trigger Run命令:按Win + R ,然后输入inetcpl.cpl ,OK。
  2. Switch to Connections tab and press Lan settings button. 切换Connections选项卡,然后按Lan settings按钮。
  3. Note down the Address and Port from "Proxy server" section. 记下 “代理服务器”部分中的地址和端口。

Question 2: In this what do I substitute for my case in tag or where can I find information that is specific to myself. 问题2:在这里我可以用标签代替我的案例,或者在哪里可以找到特定于我自己的信息。

Substitute the <host> and <port> in your settings.xml with Step 3 data. 使用Step 3数据替换settings.xml<host><port>

Question 3: Is there any correlation between users>home>.m2>settings.xml and eclipse window>preferences>general>network Connections>Active Provider(Manual)>http. 问题3:用户>主页> .m2> settings.xml与eclipse窗口>首选项>常规>网络连接>活动提供程序(手动)> http之间是否存在任何关联。 Do I need to update the same information in both places. 我是否需要在两个地方更新相同的信息。

No. They are different. 不,他们是不同的。 What mostly works in Eclipse is the Native network connection mode: Window > Preferences > General > Network Connections > Active Provider > Native . Eclipse中最常用的是Native网络连接模式: Window > Preferences > General > Network Connections > Active Provider > Native This makes Eclipse to use your native browser's settings (IE in case of Windows). 这使Eclipse可以使用您的本机浏览器设置(在Windows的情况下为IE)。

There are various sites to check if you are behind a proxy or not. 有各种网站可以检查您是否在代理服务器后面。 However, if you are behind then it must be configured in your browser; 但是,如果您落伍,则必须在浏览器中进行配置; check there to see all the information about it. 检查那里以查看有关它的所有信息。

There is a difference about the settings.xml file of Maven and network connections of Eclipse. 有关Maven的settings.xml文件和Eclipse的网络连接的不同之处。

  • settings.xml is a Maven-specific file. settings.xml是Maven特定的文件。 Whenever Maven (and Eclipse through the m2e plugin) will be searching for a dependency, it will use the proxy information located in this file. 每当Maven(以及通过m2e插件的Eclipse)将搜索依赖项时,它将使用此文件中的代理信息。
  • Network connections in Eclipse is Eclipse-specific. Eclipse中的网络连接是特定于Eclipse的。 It tells Eclipse about the proxy information when it want to connect to the Internet (through updates or marketplace). 当它想要连接到Internet时(通过更新或市场),它告诉Eclipse有关代理信息。 You can configure Eclipse to use the proxy information of your OS (typically Internet Explorer proxy settings on Windows machine). 您可以将Eclipse配置为使用操作系统的代理信息(通常是Windows计算机上的Internet Explorer代理设置)。

Also, the error message you have ( Failure to transfer ... from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced ), this is a very well known issue and it is solved by launching Maven with the -U flag . 此外,您所拥有的错误消息( Failure to transfer ... from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced ),这是一个非常著名的问题,它是通过启动Maven的解决-U标志 This flag forces Maven to update any dependencies. 此标志强制Maven更新任何依赖项。 See this question for a way to do that in Eclipse. 有关在Eclipse中执行此操作的方法, 请参阅此问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM