Maven2如何知道在哪里找到插件?

时间:2022-08-23 08:11:14

I'm using Maven2 and I can't seem to find any plugins in my repository. I'm getting errors like

我正在使用Maven2,我似乎无法在我的存储库中找到任何插件。我得到的错误就像

repository metadata for: 'org.apache.maven.plugins' could not be found on repository: myrepo

存储库元数据:'org.apache.maven.plugins'在存储库中找不到:myrepo

where myrepo is the name of my repository.

其中myrepo是我的存储库的名称。

My question is how does Maven know where to find plugins? There's a reference in my error to metadata, what metadata is expected where and what format must it take? I've not had much luck so far looking for documentation...

我的问题是Maven如何知道在哪里找到插件?我的错误中有一个对元数据的引用,预期元数据在哪里以及必须采用什么格式?到目前为止,我没有太多运气寻找文件......

(I'm not interested in the easy answer to use the central repo, I want to know why myrepo isn't working.)

(我对使用*回购的简单答案不感兴趣,我想知道为什么myrepo不工作。)

Thanks!

1 个解决方案

#1


In the root of each artifact (relative path to repository root [groupId]/[artifactId]), Maven expects to find a maven-metadata.xml file. It uses this file to determine the available versions, the latest version, and the released version.

在每个工件的根目录(存储库根目录[groupId] / [artifactId]的相对路径)中,Maven期望找到maven-metadata.xml文件。它使用此文件来确定可用版本,最新版本和已发布版本。

For example common-logging's metadata from repo1 lists all the available versions and tells us the release version is 1.1.1 as of 28th Nov 2008.

例如,repo1中的common-logging元数据列出了所有可用版本,并告诉我们截至2008年11月28日发布版本为1.1.1。

<?xml version="1.0" encoding="UTF-8"?><metadata>
  <groupId>commons-logging</groupId>
  <artifactId>commons-logging</artifactId>
  <version>1.1.1</version>
  <versioning>
    <release>1.1.1</release>
    <versions>
      <version>1.0</version>
      <version>1.0.1</version>
      <version>1.0.2</version>
      <version>1.0.3</version>
      <version>1.0.4</version>
      <version>1.1</version>
      <version>1.1.1</version>
    </versions>
    <lastUpdated>20071128191817</lastUpdated>
  </versioning>
</metadata>

Maven will download the metadata for each remote repository to your local repository (with the name maven-metadata-[repo name].xml) so it can check the available versions without having to hit each repository each time. If you want to force Maven to refetch the metadata you can do so with the "-U" switch on the commandline.

Maven会将每个远程存储库的元数据下载到本地存储库(名称为maven-metadata- [repo name] .xml),这样它就可以检查可用的版本,而无需每次都访问每个存储库。如果要强制Maven重新获取元数据,可以使用命令行上的“-U”开关执行此操作。

If you have your own repository, it needs to publish this kind of metadata so Maven can determine if any of the versions are available is the right one. The simplest way to do this is to use a repository manager like Nexus or Artifactory which will both manage the metadata for you.

如果您有自己的存储库,则需要发布此类元数据,以便Maven可以确定是否有任何版本可用。最简单的方法是使用像Nexus或Artifactory这样的存储库管理器,它将为您管理元数据。

#1


In the root of each artifact (relative path to repository root [groupId]/[artifactId]), Maven expects to find a maven-metadata.xml file. It uses this file to determine the available versions, the latest version, and the released version.

在每个工件的根目录(存储库根目录[groupId] / [artifactId]的相对路径)中,Maven期望找到maven-metadata.xml文件。它使用此文件来确定可用版本,最新版本和已发布版本。

For example common-logging's metadata from repo1 lists all the available versions and tells us the release version is 1.1.1 as of 28th Nov 2008.

例如,repo1中的common-logging元数据列出了所有可用版本,并告诉我们截至2008年11月28日发布版本为1.1.1。

<?xml version="1.0" encoding="UTF-8"?><metadata>
  <groupId>commons-logging</groupId>
  <artifactId>commons-logging</artifactId>
  <version>1.1.1</version>
  <versioning>
    <release>1.1.1</release>
    <versions>
      <version>1.0</version>
      <version>1.0.1</version>
      <version>1.0.2</version>
      <version>1.0.3</version>
      <version>1.0.4</version>
      <version>1.1</version>
      <version>1.1.1</version>
    </versions>
    <lastUpdated>20071128191817</lastUpdated>
  </versioning>
</metadata>

Maven will download the metadata for each remote repository to your local repository (with the name maven-metadata-[repo name].xml) so it can check the available versions without having to hit each repository each time. If you want to force Maven to refetch the metadata you can do so with the "-U" switch on the commandline.

Maven会将每个远程存储库的元数据下载到本地存储库(名称为maven-metadata- [repo name] .xml),这样它就可以检查可用的版本,而无需每次都访问每个存储库。如果要强制Maven重新获取元数据,可以使用命令行上的“-U”开关执行此操作。

If you have your own repository, it needs to publish this kind of metadata so Maven can determine if any of the versions are available is the right one. The simplest way to do this is to use a repository manager like Nexus or Artifactory which will both manage the metadata for you.

如果您有自己的存储库,则需要发布此类元数据,以便Maven可以确定是否有任何版本可用。最简单的方法是使用像Nexus或Artifactory这样的存储库管理器,它将为您管理元数据。