Java Maven 依赖问题 - 在中央仓库中找不到工件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18797440/
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 dependency issue - artifact not found in central repo
提问by Rohit Pandey
I'm trying to build the project from this site http://www.joptimizer.com/usage.html. I downloaded the sources jar file, unpacked it and ran maven package
in the root folder. Maven fails at the last minute saying it couldn't resolve the dependency..
我正在尝试从此站点http://www.joptimizer.com/usage.html构建项目。我下载了源 jar 文件,解压它并maven package
在根文件夹中运行。Maven 在最后一分钟失败,说它无法解决依赖关系..
could not find artifact seventytwomiles:architecture-rules:jar:3.0.0-M1 in central repo - repo.maven.apache.org/maven2 ..
I have a feeling I might need to change something in the pom.xml file for this to work, but have no idea what. Googling for this missing dependency lead me no where. In general, how would one know what to do to handle such errors (and also please help with this specific case).
我有一种感觉,我可能需要更改 pom.xml 文件中的某些内容才能使其工作,但不知道是什么。谷歌搜索这个缺失的依赖导致我无处可去。通常,人们如何知道如何处理此类错误(并且还请帮助解决此特定情况)。
采纳答案by lreeder
Specifically
具体来说
According to the Building
notes on http://www.joptimizer.com/usage.html:
根据http://www.joptimizer.com/usage.html上的Building
注释:
JOptimizer is build on maven 3.0. Before building it, you must resolve (in pom.xml) the external dependency on Colt and other dependencies that aren't in public repositories. Please refer to the "Dependencies" report for a complete treatment. For ease of use a boundle with these external libraries is provided(visit "Download"): extract the boundle in a folder and run the "maven-install.cmd" (translate it in your own shell language), and you will get the artifacts in your local repository.
JOptimizer 建立在 maven 3.0 之上。在构建它之前,您必须解决(在 pom.xml 中)对 Colt 和不在公共存储库中的其他依赖项的外部依赖项。请参阅“依赖关系”报告以获得完整的治疗。为了便于使用,提供了这些外部库的边界(请访问“下载”):将边界解压缩到文件夹中并运行“maven-install.cmd”(用您自己的 shell 语言翻译),您将获得本地存储库中的工件。
To get the bundle for this, go to http://sourceforge.net/projects/cvxopt/files/, and download the appropriate version of joptimizer-3.X.X-dependencies.zip. Unzip in your own folder, and run mvn install:install-file -DgroupId=seventytwomiles -DartifactId=architecture-rules -Dversion=3.0.0-M1 -Dpackaging=jar -Dfile=architecture-rules-3.0.0-M1.jar -DpomFile=architecture-rules-3.0.0-M1.pom
要获取此包,请访问http://sourceforge.net/projects/cvxopt/files/并下载相应版本的 joptimizer-3.XX-dependencies.zip。解压到你自己的文件夹中,然后运行mvn install:install-file -DgroupId=seventytwomiles -DartifactId=architecture-rules -Dversion=3.0.0-M1 -Dpackaging=jar -Dfile=architecture-rules-3.0.0-M1.jar -DpomFile=architecture-rules-3.0.0-M1.pom
Generally
一般来说
Use a tool like http://mavenrepository.comto search for another version of the missing dependency and update your POM with the proper version. If MVNRepository doesn't know about it, you can install the dependency yourself. If you are working with a group of developers, as Eric Jablow mentions, an artifact repository like Nexus or Artifactory is great for sharing non-public dependencies. If it's just you, you can install the artifact in your local repo as described here: How to manually install an artifact in Maven 2?
使用类似http://mavenrepository.com的工具来搜索缺少依赖项的另一个版本,并使用正确的版本更新您的 POM。如果 MVNRepository 不知道它,您可以自己安装依赖项。如果您正在与一组开发人员合作,正如 Eric Jablow 所提到的,像 Nexus 或 Artifactory 这样的工件存储库非常适合共享非公共依赖项。如果只是您,您可以按照此处所述在本地存储库中安装工件:如何在 Maven 2 中手动安装工件?
回答by Eric Jablow
You should add your own repository manager like Nexus or Artifactory. Then, find out where this dependency is kept; there are repositories other than central. If it's kept on another repository, have your repository mirror that too.
您应该添加自己的存储库管理器,例如 Nexus 或 Artifactory。然后,找出这个依赖保存在哪里;除了中央之外还有其他存储库。如果它保存在另一个存储库中,也让您的存储库镜像。
Otherwise, Nexus or Artifactory have commands to enter the dependency manually. Create a local repository called "Third-party" and add it there.
否则,Nexus 或 Artifactory 有手动输入依赖项的命令。创建一个名为“第三方”的本地存储库并将其添加到那里。
Finally, change your settings.xml
file to refer everything to your repository manager.
最后,更改您的settings.xml
文件以将所有内容都指向您的存储库管理器。
The most common case for this is when a company refuses to license their products to be held at the central repository. For example, Microsoft won't let its sqljdbc.jar
file be distributed through Central. So, you need to add it by hand.
最常见的情况是公司拒绝许可其产品存放在中央存储库中。例如,Microsoft 不会让其sqljdbc.jar
文件通过 Central 分发。因此,您需要手动添加它。
回答by Badal Singh
Change the dependency as follows
改变依赖如下
<dependency>
<groupId>org.architecturerules</groupId>
<artifactId>architecture-rules</artifactId>
<version>3.0.0-rc1</version>
<scope>test</scope>
</dependency>
Add the repository in pom
在pom中添加存储库
<repositories>
<repository>
<id>architecturerules.googlecode.com</id>
<url>http://architecturerules.googlecode.com/svn/maven2/</url>
</repository>
</repositories>