maven 3.8.1后,禁用了http作为仓库,但是内网连域名都没有,也搞不了证书。所以直接把这个限制删除即可。
方法一
直接去maven全局配置文件中,找到以下这一段,然后注释掉或者删掉即可
<mirror>
<id>maven-default-http-blocker</id>
<mirrorOf>external:http:*</mirrorOf>
<name>Pseudo repository to mirror external repositories initially using HTTP.</name>
<url>http://0.0.0.0/</url>
<blocked>true</blocked>
</mirror>
如果是自己安装的maven,全局配置文件在${maven.home}\conf\settings.xml
。
如果是IDEA内置的maven,全局配置文件在{IDEA安装目录}\plugins\maven\lib\maven3\conf\settings.xml
。
方法二
在用户配置文件%USERPROFILE%\.m2\settings.xml
中加入每个源的mirror配置。
mirrorOf
填你的私服id,url
填私服地址。
<mirror>
<id>my-nexus-http-unblocker</id>
<mirrorOf>my-nexus</mirrorOf>
<name></name>
<url>http://10.0.0.123:1234/artifactory/local-releases-virtual</url>
<blocked>false</blocked>
</mirror>
该方法原理为,maven会将全局配置和用户配置做合并,以用户配置为优先,所以maven匹配到这里配置的mirror后,就不会再匹配到禁用http的那一个mirror了。
如果使用IDEA设置或其他方法指定了用户配置文件的位置,则需要去改相应的文件。
方法三
在用户配置文件中添加以下配置,这样会直接覆盖掉全局配置中的相同id拦截。
<mirror>
<id>maven-default-http-blocker</id>
<mirrorOf>dummy</mirrorOf>
<name>Dummy mirror to override default blocking mirror that blocks http</name>
<url>http://0.0.0.0/</url>
<blocked>false</blocked>
</mirror>
我们可以使用mvn help:effective-settings
来查看合并后的配置文件信息。
报错日志
[INFO] Scanning for projects...
Downloading from Central-public: https://repo1.maven.org/maven2/com/example/example-project/1.0.1/example-project-1.0.1.pom
Downloading from aliyun-public: https://maven.aliyun.com/nexus/content/groups/public/com/example/example-project/1.0.1/example-project-1.0.1.pom
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM for com.example:example-project2:${revision}: Could not transfer artifact com.example:example-project:pom:1.0.1 from/to maven-default-http-blocker (http://0.0.0.0/): Blocked mirror for repositories: [central (http://10.0.0.123:1234/artifactory/local-releases-virtual, default, releases), snapshots (http://10.0.0.123:1234/artifactory/local-snapshots-virtual, default, releases+snapshots)] and 'parent.relativePath' points at wrong local POM @ line 6, column 13
@
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project com.example:example-project2:${revision} (D:\source\huayun\java\example-project2\pom.xml) has 1 error
[ERROR] Non-resolvable parent POM for com.example:example-project2:${revision}: Could not transfer artifact com.example:example-project:pom:1.0.1 from/to maven-default-http-blocker (http://0.0.0.0/): Blocked mirror for repositories: [central (http://10.0.0.123:1234/artifactory/local-releases-virtual, default, releases), snapshots (http://10.0.0.123:1234/artifactory/local-snapshots-virtual, default, releases+snapshots)] and 'parent.relativePath' points at wrong local POM @ line 6, column 13 -> [Help 2]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException