首页 文章

如何手动将jar安装到我的本地Maven存储库?

提问于
浏览
9

我想在我的maven项目中使用Google's GXP library . 我'm new to Maven and having quite a bit of trouble since the .jar is not available in a Maven repository already. From what I'已读过我应该能够在我的本地存储库中安装jar然后再使用它 . 但是,我遇到了很多麻烦 . 谁知道我可能出错了?

PS C:\Documents and Settings\bmccann\Desktop> mvn install:install-file -Dfile=gxp-0.2.4-beta.jar -DgroupId=com.google -DartifactId=gxp -Dversion=0.2.4-BETA -Dpackaging=jar
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'install'.
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Invalid task '.2.4-beta.jar': you must specify a valid lifecycle phase, or a goal in the format plugin:goal or pluginGroupId:pluginArtifactId:pluginVersi
on:goal
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time:

2 回答

  • 1

    您正在使用的命令没问题 . 我只是复制并粘贴它并在我的本地存储库中成功安装了相同的新下载的jar:

    pascal@laptop:~/Downloads$ mvn install:install-file -Dfile=gxp-0.2.4-beta.jar -DgroupId=com.google -DartifactId=gxp -Dversion=0.2.4-BETA -Dpackaging=jar
    [INFO] Scanning for projects...
    [INFO] Searching repository for plugin with prefix: 'install'.
    [INFO] ------------------------------------------------------------------------
    [INFO] Building Maven Default Project
    [INFO]    task-segment: [install:install-file] (aggregator-style)
    [INFO] ------------------------------------------------------------------------
    [INFO] [install:install-file {execution: default-cli}]
    [INFO] Installing /home/pascal/Downloads/gxp-0.2.4-beta.jar to /home/pascal/.m2/repository/com/google/gxp/0.2.4-BETA/gxp-0.2.4-BETA.jar
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESSFUL
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 2 seconds
    [INFO] Finished at: Wed Dec 09 08:44:37 CET 2009
    [INFO] Final Memory: 3M/53M
    [INFO] ------------------------------------------------------------------------
    

    所以你必须对 maven-install-plugin 插件有问题(可能在下载不完整后损坏) . 删除 ~/.m2/repository/org/apache/maven/plugins/maven-install-plugin (或 ~/.m2/repository/org/apache/maven 下的更多内容)并再试一次 .

  • 11

    谢谢你的建议 . 在发布之前我曾尝试过这两个,但都没有奏效 . 事实证明,这对我不起作用,因为我使用的是Windows PowerShell . 如果我使用标准命令控制台,那么它工作正常 . 我想PowerShell或Maven中都存在一个错误,它不会让两者正常交互 .

相关问题