Eclipse 配置的 Maven 设置代理

200 阅读1分钟

设置settings.xml 文件

要设置 maven 代理设置,请执行以下步骤:

  • 导航到路径 – {M2_HOME} conf/settings.xml
  • 在任何文本编辑器中以编辑模式打开文件settings.xml
  • 打开并更新<proxy>标签。

该标签如下所示:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

	<!-- proxies
	| This is a list of proxies which can be used on this machine to connect to the network.
	| Unless otherwise specified (by system property or command-line switch), the first proxy
	| specification in this list marked as active will be used.
	|-->
	<proxies>
		<!-- proxy
		 | Specification for one proxy, to be used in connecting to the network.
		 |
		<proxy>
			<id>optional</id>
			<active>true</active>
			<protocol>http</protocol>
			<username>proxyuser</</username>
			<password>proxypass</password>
			<host>proxy.host.net</host>
			<port>80</port>
			<nonProxyHosts>local.net|some.host.com</nonProxyHosts>
		</proxy>
		-->
	</proxies>

</settings>

更新 Eclipse 的 Maven 配置

要在使用 Maven 时在 eclipse 中使用代理设置,请按照下列步骤操作:

  • 打开 Eclipse,然后转到窗口 -> 首选项。

  • 点击User SettingsBrowse按钮,并选择settings.xmlb836ae80450f23a6a4dfb5c91c56a574_830x465.webp Eclipse 中的 Maven 代理

  • 单击"Update Settings"按钮更新设置。 如果出现任何确认对话框,只需单击“是”。