maven疑难杂症
约 215 字小于 1 分钟
2025-06-25
问题一:
报错:
Could not transfer artifact com.wshoto:wshoto-open-server-sdk:jar:1.0.4-SNAPSHOT from/to maven-default-http-blocker (http://0.0.0.0/): Blocked mirror for repositories: [wshoto-mirror (http://nexus.private.com/repository/maven-public/, default, releases+snapshots)]原因:
- Maven 从 3.8.0 开始,默认在 settings.xml 中启用了一个叫 maven-default-http-blocker 的机制;
- 它会阻止所有使用 HTTP 协议的仓库(mirror 或 repository);
- 目的是为了防止中间人攻击(MITM),保障依赖下载的安全性。
解决:
- 将私库地址改为 HTTPS(推荐)
- 临时允许使用 HTTP(开发环境可用)
<!-- 关键配置:允许 HTTP -->
<profiles>
<profile>
<id>allow-http</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<maven.repository.redirections.allowUntrusted>true</maven.repository.redirections.allowUntrusted>
</properties>
</profile>
</profiles>问题二:
报错:
拉不下某个依赖
原因:
配置问题
解决:
手动拉取
mvn install:install-file \
-Dfile=path/to/wshoto-open-server-sdk-1.0.4-SNAPSHOT.jar \
-DgroupId=com.wshoto \
-DartifactId=wshoto-open-server-sdk \
-Dversion=1.0.4-SNAPSHOT \
-Dpackaging=jar