使用maven3.8以上版本时候,错误信息:Since Maven 3.8.1 http repositories are blocked.
- 工作小总结
- 时间:2024-01-30 17:30
- 1740人已阅读
🔔🔔🔔好消息!好消息!🔔🔔🔔
有需要的朋友👉:联系凯哥
背景:
maven使用的是3.9.1。请求私服是http方式。
错误信息:
Blocked mirror for repositories: [central (http://192.168.1.1/repository/maven-public/, default, releases+snapshots), snapshots (http://192.168.1.1/repository/maven-snapshots/, default, releases+snapshots), aliyun-maven-content-public (http://maven.aliyun.com/nexus/content/groups/public/, default, releases+snapshots)]
Since Maven 3.8.1 http repositories are blocked.
Possible solutions:
Check that Maven settings.xml does not contain http repositories
Check that Maven pom files do not contain http repository http://192.168.1.1/repository/maven-public/
Check that Maven pom files do not contain http repository http://192.168.1.1/repository/maven-snapshots/
Check that Maven pom files do not contain http repository http://maven.aliyun.com/nexus/content/groups/public/
Add a mirror(s) for http://192.168.1.1/repository/maven-public/, http://192.168.1.1/repository/maven-snapshots/, http://maven.aliyun.com/nexus/content/groups/public/ that allows http url in the Maven settings.xml
Downgrade Maven to version 3.8.1 or earlier in settings
错误原因:
从Maven 3.8.1版本开始,出于安全原因,默认阻止了对HTTP仓库的访问,推荐使用HTTPS。你的错误信息表明你的Maven配置中包含了HTTP仓库地址。
解决方法:
升级仓库为HTTPS:如果可能的话,将你的私有仓库和阿里云仓库升级为支持HTTPS协议,并在
settings.xml
文件中更新对应的URL。
<mirrors> <mirror> <id>your-mirror-id</id> <name>Your Repository Name</name> <url>https://192.168.1.1/repository/maven-public/</url> <!-- 使用HTTPS --> <mirrorOf>*</mirrorOf> </mirror> <!-- 同理,更新其他仓库的URL --> </mirrors>
2.暂时禁用HTTP检查:如果不方便立即升级为HTTPS,你可以在Maven的settings.xml
中添加全局配置来临时禁用HTTP检查。
<settings> ... <profiles> <profile> <id>allow-http</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <maven.repo.http.protocol>http</maven.repo.http.protocol> </properties> </profile> </profiles> <activeProfiles> <activeProfile>allow-http</activeProfile> </activeProfiles> ... </settings>
3.降低maven版本
凯哥采用的就是这种方案