我正在尝试通过 maven 版本插件更新我的依赖项,但我无法这样做,因为它没有通过我的代理。
mvn versions:update-properties
我的防火墙日志显示它在尝试直接访问 Internet 时正在断开端口 443 上的连接;但是,我在 ~/.m2/settings.xml 中指定了一个代理:
<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>
<proxy>
<host>${HOSTNAME_GOES_HERE}</host>
<port>${PORT_GOES_HERE}</port>
<active>true</active>
</proxy>
</proxies>
有没有办法在不更改我的防火墙规则的情况下让它工作?
谢谢,
沃尔特
最佳答案
似乎 versions-maven-plugin
在代理设置中错误地使用了协议(protocol)标记。在我将协议(protocol)标记更改为 https
之后,versions-maven-plugin
按预期使用了我的代理服务器:
<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>
<proxy>
<host>${HOSTNAME_GOES_HERE}</host>
<port>${PORT_GOES_HERE}</port>
<protocol>https</protocol>
<active>true</active>
</proxy>
</proxies>
</settings>
这确实符合以下 Github 问题:https://github.com/mojohaus/versions-maven-plugin/issues/421
但是,这并不反射(reflect) Maven 预期的用法。此答案表明协议(protocol)标记适用于 proxy-server
而不是 target-url
的协议(protocol):https://stackoverflow.com/a/52508940/5945416
Maven 对我来说工作得很好,协议(protocol)标记设置为 https 而不是 http,并且版本插件在我切换回 http 后立即出现问题,因此我将保留它。
测试于:
- 专家:3.8.1
- 版本-maven-plugin:2.8.1
关于Maven 版本插件不遵守代理设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57046107/