在Maven下代理服务器设定的方式
作者:liumiaocn 时间:2023-10-15 02:17:13
在很多场景下,maven不能直接访问到外网时,使用代理是其中常见的一种方式。这篇文章整理一下常见的maven中设置代理的方法。
代理服务器
代理服务器的搭建,可以使用nginx,或者更为专业一点的使用squid,轻松实现http和https方式。
maven代理服务器设定
方法1: 设定settings.xml
通过设定全局或者局部的proxy段即可设定代理服务器,一般为注视掉。使用例:
<proxies>
<proxy>
<id>optional</id>
<active>true</active>
<protocol>http</protocol>
<username>用户名</username>
<password>用户密码</password>
<host>ip或者代理服务器的url</host>
<port>端口</port>
<nonProxyHosts>无需使用代理访问的地址</nonProxyHosts>
</proxy>
</proxies>
设定说明
方法2: 在mvn命令中通过-D传入运行时设定
方法1适合与长期保存的内容,如果需要临时的变更性的设定或者不太方便修改pom文件的情况下,择适合使用这种方法进行设定,其实从根本上来说,这是JVM的设定,自然mvn也是这样使用的。
使用例(https方式):mvn compile -Dhttps.proxyHost=192.168.163.118 -Dhttps.proxyPort=3128
小结
这篇文章总结了maven下如何设定代理的方式,主要是使用pom文件设定或者运行时传入代理服务器信息,都是常用的maven代理的设定方式。
来源:https://blog.csdn.net/liumiaocn/article/details/83537115
标签:maven,代理,服务器,设定
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Spring如何使用@Indexed加快启动速度
2022-05-02 10:50:40
![](https://img.aspxhome.com/file/2023/6/62236_0s.jpg)
Android EditText限制输入整数和小数的位数的方法示例
2022-12-23 05:15:30
深入分析C# Task
2022-10-24 12:39:00
Springboot整合Freemarker的实现详细过程
2023-01-23 22:09:57
![](https://img.aspxhome.com/file/2023/4/84164_0s.jpg)
Java 程序员掌握 Spring Boot非常有必要
2021-06-27 19:06:52
![](https://img.aspxhome.com/file/2023/1/113511_0s.png)
Nginx+SpringCloud Gateway搭建项目访问环境
2023-07-16 01:13:27
![](https://img.aspxhome.com/file/2023/5/76505_0s.jpg)
C# wpf Grid中实现控件拖动调整大小的示例代码
2023-05-15 17:12:03
![](https://img.aspxhome.com/file/2023/0/94650_0s.png)
java 中Map详解及实例代码
2023-06-06 01:27:37
JetCache 缓存框架的使用及源码解析(推荐)
2021-07-23 12:21:25
![](https://img.aspxhome.com/file/2023/2/64402_0s.png)
System.getProperty(user.dir)定位问题解析
2023-11-20 08:50:44
![](https://img.aspxhome.com/file/2023/8/79198_0s.png)
Unity实现图形相交检测
2021-09-16 09:31:01
![](https://img.aspxhome.com/file/2023/8/80068_0s.jpg)
c# 防火墙添加/删除 特定端口的示例
2023-12-22 21:56:41
![](https://img.aspxhome.com/file/2023/7/98247_0s.png)
Android极光推送处理message遇到的坑解决
2022-08-08 00:49:32
![](https://img.aspxhome.com/file/2023/8/105978_0s.jpg)
Android 安全加密:Https编程详解
2023-11-08 06:58:51
![](https://img.aspxhome.com/file/2023/5/139215_0s.png)
Java实例讲解多态数组的使用
2021-08-30 19:34:46
![](https://img.aspxhome.com/file/2023/5/84305_0s.png)
C#实现图形区域组合操作的方法
2023-05-01 19:08:21
Mybatis Plus中的流式查询案例
2023-08-18 16:35:13
java 深拷贝与浅拷贝机制详解
2023-02-18 19:00:59
spring boot 注入 property的三种方式(推荐)
2023-01-23 05:10:27
java使用dom4j操作xml示例代码
2022-03-21 18:28:38