【问题标题】:How to get the jar file of a maven library?如何获取maven库的jar文件?
【发布时间】:2018-01-30 20:36:48
【问题描述】:

我想在一个小项目中使用this 库。我知道如何将 jar 文件添加到我的项目中,但我不知道如何使用 maven。我在 cmd 中尝试了命令 mvn clean package 但在安装 maven 之后它只是错误:

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.070 s
[INFO] Finished at: 2017-08-22T18:23:04+04:30
[INFO] Final Memory: 5M/123M
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (C:\Users\aran). Please verify you invoked Maven from the correct directory. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MissingProjectException

我试图在项目目录中打开 cmd 但没有帮助。 谁能帮我找到那个库的jar文件?或者给我一些关于如何使用 maven 的说明?

【问题讨论】:

  • 您需要在项目的根目录中创建一个文件 pom.xml 并在其中添加您需要的 Jar 作为依赖项
  • 查看报错信息最后一行的链接...
  • 你的问题有点笼统。通常,如果您想使用 Maven 构建项目,则项目需要在其根目录中有一个文件 pom.xml。你得到的错误似乎是说没有找到这样的文件。您需要找出原因,并可能使用这些详细信息编辑您的问题(是的,当您调用此函数时,您确实需要位于项目自己的文件夹中)

标签: java git maven jar package


【解决方案1】:

我试过命令 mvn clean package

尝试在项目目录中执行相同的命令(例如 cd /User/you/yourFolder/mp3agic/):

mvn clean package

同样在你项目的 pom.xml 文件中,你需要为链接的项目包含这个依赖:

<dependency>
    <groupId>com.mpatric</groupId>
    <artifactId>mp3agic</artifactId>
    <version>0.9.0</version>
</dependency>

编辑:如果您的项目不是基于 maven(如下面的 cmets 所述),您应首先将项目转换为 maven 项目,该项目将创建所需的pom.xml,然后在项目上使用上述命令。这将有助于 -IntelliJ - Convert a Java project/module into a Maven project/module

【讨论】:

  • 我没有任何“pom.xml”。我的项目目录是:“Z:\my files\projects\programing\java\captionBot”,如果有帮助,我正在使用 intellij。
  • @aran 你应该 first convert the project into maven 创建所需的 pom.xml 然后在项目上使用上述命令。
【解决方案2】:

您可以从here 下载 jar 文件并将其添加到您的类路径中。

下载链接就在文件旁边。

【讨论】:

    猜你喜欢
    • 2015-11-28
    • 2021-12-21
    • 2012-05-03
    • 2018-09-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多