英文:
Non-parse POM. POM in .m2 folder corrupted
问题
你好,我正尝试构建一个 Spring 项目,使用命令 mvn package -DskipTests
,但是我遇到了以下错误。
以下是错误日志:
> [INFO] 正在扫描项目...
[ERROR] [ERROR] 在处理 POM 文件时遇到了一些问题:
[FATAL] 无法解析的 POM /home/.m2/repository/org/springframework/boot/spring-boot-starter-parent/2.0.3.RELEASE/spring-boot-starter-parent-2.0.3.RELEASE.pom:预期的根元素为 'project',但找到了 'html'(位置:在 START_TAG 处看到 ..." "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html>... @1:127) @ /home/.m2/repository/org/springframework/boot/spring-boot-starter-parent/2.0.3.RELEASE/spring-boot-starter-parent-2.0.3.RELEASE.pom,第 1 行,第 127 列
当我在 Google 上搜索了关于这个错误的信息时,我在某个地方看到说,当你在代理后面运行 Maven 时,它将无法访问中央 Maven 仓库(因此无法下载)。因此可能会出现这个错误。
我正在 Ubuntu 上运行,系统代理已关闭。我尝试在虚拟机上运行相同的命令,但是遇到了相同的问题。
请问如何解决这个错误?
谢谢!
英文:
Hello I am try to build mvn package -DskipTests
a spring project and I get the following error.
Following is the error log
> [INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[FATAL] Non-parseable POM /home/.m2/repository/org/springframework/boot/spring-boot-starter-parent/2.0.3.RELEASE/spring-boot-starter-parent-2.0.3.RELEASE.pom: Expected root element 'project' but found 'html' (position: START_TAG seen ..." "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html>... @1:127) @ /home/.m2/repository/org/springframework/boot/spring-boot-starter-parent/2.0.3.RELEASE/spring-boot-starter-parent-2.0.3.RELEASE.pom, line 1, column 127
When I googled about this error, I read somewhere that when you run maven behind a proxy, it will not be able to access the central maven (Hence not able to download). And hence this error might occur.
I am running on Ubuntu and system proxy is OFF.I tried running the same on a VM, I faced the same problem.
How can I resolve this error?
Thank you!!
答案1
得分: 1
这里有几件事情正在进行。
(这是您的Maven正在尝试下载的构件的描述页面链接:https://search.maven.org/classic/#artifactdetails%7Corg.springframework.boot%7Cspring-boot-starter-parent%7C2.0.3.RELEASE%7Cpom)。
当您请求不存在的内容时(您预期会收到404错误),您却得到了一个HTML页面,这要归功于Verizon的干预和混乱。Verizon默认启用了一个可怕的功能,称为“Search Assist”。基本上,它确保在您的HTTP客户端(在此情况下为Maven)请求失败时,会发送一个200响应,其中包含一些旨在增加他们广告收入的HTML内容。幸运的是,您可以关闭它。
我不知道为什么您的Maven找不到相关的发布版本。
英文:
There are several things going on here.
(Here is the link to the description page for the artifact that your Maven is trying to download: https://search.maven.org/classic/#artifactdetails%7Corg.springframework.boot%7Cspring-boot-starter-parent%7C2.0.3.RELEASE%7Cpom).
The reason you're getting an HTML page when you ask for something that doesn't exist (you'd expect to get a 404) is thanks to Verizon jumping in and screwing everything up. Verizon has a horrible, godawful feature enabled by default called "Search Assist". Basically, it ensures that instead of a 404 being returned to your HTTP client (Maven in this case), a 200 response will be sent instead with some HTML in it that is designed to boost their advertising revenue. Fortunately you can turn it off.
I don't know why your Maven is not finding the release in question.
答案2
得分: 0
问题已解决。问题出在我的 DNS 上。
DNS 查询必须在其他地方进行,而不是 Verizon 默认提供的方式。
步骤:
- 编辑 sudo vim /etc/resolv.conf
- 注释掉最后两行,并将 nameserver 改为 1.1.1.1
nameserver 1.1.1.1
#options *****
#search .
- 使用 sudo netplan apply 重新启动网络
- 删除 ./m2 文件夹
- 运行 mvn clean package 来安装所有的包。
英文:
The issue is resolved. The problem was with my dns.
The dns lookup has to do be done elsewhere instead of what verizon provides by default.
Steps:
- Edit sudo vim /etc/resolv.conf
- Comment out last two lines, and change nameserver to 1.1.1.1
nameserver 1.1.1.1
#options *****
#search .
- Restart network using sudo netplan apply
- Delete ./m2 folder
- Build mvn clean package to install all the packages.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论