Maven 添加 WorldEdit 依赖项

Maven add WorldEdit Dependencies

如何将这个 WorldEdit 依赖项添加到我的 Maven 项目中? http://maven.sk89q.com/artifactory/repo/com/sk89q/worldedit/worldedit-bukkit/ 我需要 6.1.1-SNAPSHOT。

有没有算法可以得到 群组编号 工件编号 和版本?

了解手头的任务很重要。 Maven 根据其唯一的 坐标 从远程 存储库 下载 dependencies。有两种存储库:

  • 发布存储库,托管发布版本的依赖项,即最终版本。
  • 托管依赖项快照版本的快照存储库,即当前正在开发中的版本,还不稳定。

Maven 坐标是一个集合(groupId, artifactId, version)。它唯一标识每个依赖项(说实话,实际上有一个包装和一个可能的分类器,但在这里并不重要)。

您的问题是声明对 worldedit-bukkit-6.1.1-SNAPSHOT 依赖项的依赖项。让我们看看:

  • 此处的存储库是 http://maven.sk89q.com/artifactory/repo:它是您链接到的 URL 的根目录。
  • groupId 是 com.sk89q.worldedit:这是 URL 的其余部分,就在
  • 之前
  • artifactId,即worldedit-bukkit
  • 版本,即6.1.1-SNAPSHOT

如果你分解URL,你会得到

http://maven.sk89q.com/artifactory/repo/com/sk89q/worldedit/worldedit-bukkit/6.1.1-SNAPSHOT/

转换为以下 Maven 坐标:

{REPOSITORY_URL}/{groupId where dots are slashes}/{artifactId}/{version}/

所以现在,我们需要告诉 Maven 有关存储库的信息。默认情况下,Maven 在所谓的 Maven Central, so we need to add this repository. This is done either in the POM or in the settings.xml file, by adding the following configuration:

中查找工件
<repositories>
  <repository>
    <id>sk89q-snapshots</id>
    <url>http://maven.sk89q.com/artifactory/repo</url>
    <releases>
      <enabled>true</enabled> <!-- releases enabled: this specific repository also hosts release versions -->
    </releases>
    <snapshots>
      <enabled>true</enabled> <!-- snapshots enabled: we declare a SNAPSHOT repository because we need to download a SNAPSHOT dependency -->
    </snapshots>
  </repository>
</repositories>

下一步是实际声明依赖项。这是在 POM 中完成的,配置如下:

<dependency>
  <groupId>com.sk89q.worldedit</groupId>
  <artifactId>worldedit-bukkit</artifactId>
  <version>6.1.1-SNAPSHOT</version>
</dependency>

就是这样!