mvn install不在本地存储库中创建jar文件

时间:2015-09-22 18:08:48

标签: java maven ant

我的项目中有pom.xml方向的util文件:

   <?xml version="1.0" encoding="UTF-8"?>
   <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <parent>
            <groupId>com.myapp.app</groupId>
            <artifactId>MyApp</artifactId>
            <version>1.0-SNAPSHOT</version>
        </parent>

       <artifactId>util</artifactId>
       <packaging>jar</packaging>
       <version>1.0-SNAPSHOT</version>
       <name>Util</name>
       <url>http://maven.apache.org</url>
         ...
         <other things here>
       </project>

当我执行mvn clean install时,它运行正常。但是,当我尝试使用util依赖项时,我得到:

[ERROR] Failed to execute goal on project helloworld: Could not resolve dependencies for project com.myapp.app:helloworld:jar:1.0-SNAPSHOT: Could not find artifact com.myapp.app:util:jar:1.0-SNAPSHOT -> [Help 1]

展望~/.m2/repository/我没有看到util目录。为什么会这样?如何让maven在本地存储库中安装这些软件包?

************************** Last 15 lines *******************
[INFO] Copying jdom-1.0.jar to myapp/util/target/dependency/jdom-1.0.jar
[INFO] Copying httpclient-4.2.6.jar to /myapp/util/target/dependency/httpclient-4.2.6.jar
[INFO] Copying maven-scm-provider-svn-commons-1.4.jar to myapp/util/target/dependency/maven-scm-provider-svn-commons-1.4.jar
[INFO] Copying aws-java-sdk-cloudsearch-1.9.34.jar to myapp/util/target/dependency/aws-java-sdk-cloudsearch-1.9.34.jar
[INFO] Copying jdom2-2.0.4.jar to myapp/util/target/dependency/jdom2-2.0.4.jar
[INFO] Copying poi-scratchpad-3.12-beta1.jar to myapp/util/target/dependency/poi-scratchpad-3.12-beta1.jar
[INFO] Copying aws-java-sdk-cognitoidentity-1.9.34.jar to myapp/util/target/dependency/aws-java-sdk-cognitoidentity-1.9.34.jar
[INFO] Copying elasticsearch-1.4.2.jar to myapp/util/target/dependency/elasticsearch-1.4.2.jar
[INFO] Copying c3p0-0.9.1.1.jar to myapp/util/target/dependency/c3p0-0.9.1.1.jar
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ util ---
[INFO] Installing myapp/util/target/util-1.0-SNAPSHOT.jar to ~/.m2/repository/com/myapp/app/util/1.0-SNAPSHOT/util-1.0-SNAPSHOT.jar
[INFO] Installing myapp/util/pom.xml to ~/.m2/repository/com/myapp/app/util/1.0-SNAPSHOT/util-1.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.855 s
[INFO] Finished at: 2015-09-22T11:32:59-07:00
[INFO] Final Memory: 43M/465M
[INFO] ------------------------------------------------------------------------

1 个答案:

答案 0 :(得分:2)

当您执行mvn clean install时,请查看[INFO] Installing行,看看它安装软件包的位置,也许您的配置错误。

上面的日志显示该软件包安装正确。 请告诉我们如何定义在hello world中使用的依赖项。