Java maven:无法安装元数据项目无法解析元数据 maven-metadata-local.xml:在开始标记之前只允许空白内容
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26024582/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
maven : Failed to install metadata project Could not parse metadata maven-metadata-local.xml: only whitespace content allowed before start tag
提问by jeraldfdo
Got this error when I was trying to build a project which I just downloaded from SVN.
当我试图构建一个我刚刚从 SVN 下载的项目时遇到了这个错误。
Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.4:install (default-install) on project : Failed to install metadata project:1.0-SNAPSHOT/maven-metadata.xml: Could not parse metadata C:\Users.m2\project\1.0-SNAPSHOT\maven-metadata-local.xml: only whitespace content allowed before start tag and not \u0 (position: START_DOCUMENT seen \u0... @1:1) -> [Help 1]
无法在项目上执行目标 org.apache.maven.plugins:maven-install-plugin:2.4:install (default-install):无法安装元数据项目:1.0-SNAPSHOT/maven-metadata.xml:无法解析元数据 C :\Users.m2\project\1.0-SNAPSHOT\maven-metadata-local.xml: 开始标签前只允许空白内容而不是 \u0 (位置: START_DOCUMENT 看到 \u0... @1:1) -> [帮助1]
采纳答案by jeraldfdo
I just wanted to document this error on the internet. There was no much help or I didn't search properly.
我只是想在互联网上记录这个错误。没有太多帮助,或者我没有正确搜索。
Answer:
回答:
Go to the the path where the maven-metadata-local.xml
is. Delete the project folder along with the xml
and build the project.
去那里的路径maven-metadata-local.xml
。删除项目文件夹以及xml
构建项目。
It worked for me!
它对我有用!
回答by Amine Aouffen
We got the same problem in a project right after modifying the pom.xml
to add some plugins and configurations.
Deleting the project folders from maven local repository cache solved it.
我们在修改pom.xml
添加一些插件和配置后,在一个项目中遇到了同样的问题。从 Maven 本地存储库缓存中删除项目文件夹解决了它。
回答by user2818782
By adding the
通过添加
" -Dmaven.repo.local=$WORKSPACE/.repository"
“ -Dmaven.repo.local=$WORKSPACE/.repository”
argument to your mvn install command it forces Maven to use a local private repository, instead of the central one (~/.m2/repository).
作为 mvn install 命令的参数,它强制 Maven 使用本地私有存储库,而不是中央存储库 (~/.m2/repository)。
Every Maven build will start with a fresh repository, thus avoiding such conflicts. This trick does however come with the caveat that it now needs to download EvERYTHING. So expect dramatically increased network traffic (not a problem if you use a local Nexus as a mirror), and slightly longer build times.
每个 Maven 构建都将从一个新的存储库开始,从而避免此类冲突。然而,这个技巧确实伴随着它现在需要下载所有东西的警告。因此,预计网络流量会显着增加(如果您使用本地 Nexus 作为镜像,这不是问题),并且构建时间会稍长一些。
回答by ETN
Deleting the project folder and the maven-metadata-local.xml in the local repository solves the problem as stated by eugene-s's answer.
删除本地存储库中的项目文件夹和 maven-metadata-local.xml 解决了 eugene-s's answer所述的问题。
Even though the problem in the question does not seem to be caused by concurrent usage of the local maven repository, this problem often occurs in a CI environment when the various jobs use the same maven local repository system.
尽管题中的问题似乎不是本地maven仓库并发使用造成的,但是这个问题经常出现在CI环境中,各个作业使用同一个maven本地仓库系统。
You can either go with the solution (by user2818782) to always user a fresh repository, or you can start using https://github.com/takari/takari-local-repositorywhich is a replacement to the local maven repository that is safe for concurrent access.
您可以使用解决方案(由 user2818782 提供)始终使用新的存储库,或者您可以开始使用https://github.com/takari/takari-local-repository,它是安全的本地 maven 存储库的替代品用于并发访问。