安装第三方JAR

时间:2017-09-18 09:34:52

标签: java maven spring-boot maven-2 maven-3

我在Eclipse中有一个名为TdkUtils的maven项目,带有这个pom.xml: 这是一个utils项目。所以我想创建一个jar,将它放在存储库中并在另一个项目中使用它。

...
<groupId>com.tdk</groupId>
  <artifactId>tdkUtils</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>tdkUtils</name>
...

但是我在安装插件时遇到了这些错误:

MacBook-Pro-de-nunito:tdkUtils nunito$ mvn install:install-file -Dfile=target/tdkUtils-0.0.1-SNAPSHOT.jar
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building tdkUtils 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ tdkUtils ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.353 s
[INFO] Finished at: 2017-09-18T11:29:58+02:00
[INFO] Final Memory: 9M/309M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.4:install-file (default-cli) on project tdkUtils: The artifact information is incomplete or not valid:
[ERROR] [0]  'groupId' is missing.
[ERROR] [1]  'artifactId' is missing.
[ERROR] [2]  'packaging' is missing.
[ERROR] [3]  'version' is missing.
[ERROR] -> [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/MojoExecutionException

2 个答案:

答案 0 :(得分:3)

如果您只是在使用util mvn install文件的同一目录中执行pom.xml,maven会将jar文件安装到用户的本地存储库中。

之后,jar文件可以由其他项目的同一用户使用。

答案 1 :(得分:0)

你可以在没有像这样的pom.xml的情况下将jar安装到本地仓库: ion-title