将maven创建的jar文件安装到本地仓库

Mr.*_*r.Q 1 java maven

是我或maven文档是无用的,因为在链接下面:

链接

它说如果你已经通过maven生成了jar文件,你可以通过以下命令安装它:

mvn org.apache.maven.plugins:maven-install-plugin:2.5.1:install-file -Dfile=<path-to-file>
Run Code Online (Sandbox Code Playgroud)

但是当我尝试这个:

mvn install:install-file -Dfile=E:\jarFiles\utill-1.0.jar -DlocalRepositoryPath=E:\repo
Run Code Online (Sandbox Code Playgroud)

它给了我以下错误:

The artifact information is incomplete or not valid:
[ERROR] [0]  'groupId' is missing.
[ERROR] [1]  'artifactId' is missin
[ERROR] [2]  'packaging' is missing
[ERROR] [3]  'version' is missing.
Run Code Online (Sandbox Code Playgroud)

Abi*_*san 7

您还必须提供这些信息(groupId,artifactId,包装,版本).使用以下命令并根据需要替换内容.

mvn install:install-file  -Dfile=path-to-your-artifact-jar \
                          -DgroupId=your.groupId \
                          -DartifactId=your-artifactId \
                          -Dversion=version \
                          -Dpackaging=jar \
                          -DgeneratePom=true
Run Code Online (Sandbox Code Playgroud)

点击此处了解更多详情


小智 5

这应该工作.

mvn org.apache.maven.plugins:maven-install-plugin:2.5.2:install-file -Dfile=<path-to-file>
Run Code Online (Sandbox Code Playgroud)