maven项目如何添加依赖? (如何从外部 jar 文件中找出 GroupID / ArtifactID)

How to add dependency to maven project? (How to find out GroupID / ArtifactID from external jar file)

我想将 "html2image" 库添加到我的项目中,以便在我的代码中使用它。 但我不明白,pom.xml 看起来像什么。

这是我的 pom.xml 目前的样子:

pom image

我添加了第 33 行到 37 行和第 48 行到 52 行。

我知道我需要这个参数,但我不知道在标签之间写什么。 您可以在左侧看到我的 3 个 jar 文件。这三个文件创建了一个lib文件夹。

请帮忙!

通常当我想向我的maven 项目中添加一些库时,我google [library name] maven,然后从http://mvnrepository.com/ 中选择结果。在那里你会找到你正在寻找的 groupId、artifactId 和版本号。

这是一个相关的例子:http://mvnrepository.com/artifact/com.github.xuwei-k/html2image/0.1.0

您的项目中不需要该 jar。如果您需要的库不在 Maven 存储库中,您只需要一个单独的库文件夹!

转到 http://mvnrepository.com,搜索依赖项,然后将 pom 中的代码段复制粘贴到依赖项部分(必须在 xml 树中的项目下方),如下所示

<project>
  <dependencies>
   <dependency>
     <groupId>com.github.xuwei-k</groupId>
     <artifactId>html2image</artifactId>
     <version>0.1.0</version>
   </dependency>
  </dependencies>
</project>

更新项目(如果没有自动更新,按alt+F5)。完成!