Xml 为什么maven无法收集另一个内部依赖项目?
我的整个pom结构如下所示:Xml 为什么maven无法收集另一个内部依赖项目?,xml,maven,pom.xml,Xml,Maven,Pom.xml,我的整个pom结构如下所示: simple-parent2-| |-pom.xml |-simple-model2-| pom.xml |-simple-weather2-| pom.xml <?xml version="1.0" encoding="UTF-8"?>
simple-parent2-|
|-pom.xml
|-simple-model2-|
pom.xml
|-simple-weather2-|
pom.xml
<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>kursk.practice.ch07</groupId>
<artifactId>simple-parent2</artifactId>
<version>1.1</version>
<packaging>pom</packaging>
<name>simple-parent2</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<modules>
<module>simple-model2</module>
<module>simple-weather2</module>
<!--
<module>simple-persist2</module>
<module>simple-webapp2</module>
<module>simple-command2</module>
-->
</modules>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
simple-weather2依赖于simple-model2
因此,simple-parent2 pom.xml如下所示:
simple-parent2-|
|-pom.xml
|-simple-model2-|
pom.xml
|-simple-weather2-|
pom.xml
<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>kursk.practice.ch07</groupId>
<artifactId>simple-parent2</artifactId>
<version>1.1</version>
<packaging>pom</packaging>
<name>simple-parent2</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<modules>
<module>simple-model2</module>
<module>simple-weather2</module>
<!--
<module>simple-persist2</module>
<module>simple-webapp2</module>
<module>simple-command2</module>
-->
</modules>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
第二,我在simple-weather2文件夹上执行dependency:tree,但maven report无法收集simple-model2和simple-parent2
kursk@KURSK-PC /D/CodeSpace/maven/simple-parent2/simple-weather2
$ mvn dependency:tree
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building simple-weather2 1.1
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.411s
[INFO] Finished at: Sat Mar 08 16:27:19 CST 2014
[INFO] Final Memory: 7M/122M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project simple-weather2: Could not resolve dependencies for project kursk.practice.ch07:simple-weather2:jar:1.1: Failed to collect de
pendencies at kursk.practice.ch07:simple-model2:jar:1.1: Failed to read artifact descriptor for kursk.practice.ch07:simple-model2:jar:1.1: Failure to find kursk.practi
ce.ch07:simple-parent2:pom:1.1 in http://dev.joget.org/archiva/repository/internal/ was cached in the local repository, resolution will not be reattempted until the up
date interval of joget-internal has elapsed or updates are forced -> [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/DependencyResolutionException
但我可以在本地存储库的存储库中找到它们
kursk@KURSK-PC /C/Users/kursk/.m2/repository/kursk/practice/ch07
$ ls -l
total 0
drwxr-xr-x 4 kursk Administ 0 Mar 8 15:06 simple-model2
drwxr-xr-x 3 kursk Administ 0 Mar 8 15:07 simple-parent2
我的步骤有什么问题?为什么maven找不到内部依赖项目?对不起,这是我的错,我没有完全阅读。现在,我明白了 我没有执行simple-parent2项目中的“mvn clean install”,所以simple-parent2和simple-model2 jar文件没有位于本地缓存中 在simple-parent2项目的exec“mvn clean install”之后,simple-weather2项目的exec“mvn dependency:tree”就可以工作了 因此,以下文字摘自《maven权威指南》 当Maven针对具有子模块的项目执行时,Maven首先加载 父POM并定位所有子模块POM。Maven然后把所有这些 将POM投射到一种叫做Maven反应堆的东西中,该反应堆分析 模块之间的依赖关系。反应器负责将组件订购到 确保按照正确的顺序编译和安装相互依赖的模块 注: 反应器保留POM中定义的模块顺序,除非 需要作出改变。对此,一个有用的心智模型是描绘 依赖于兄弟项目的模块被“下推” 直到满足依赖项顺序为止。在极少数情况下,它 可以方便地重新排列构建的模块顺序——例如 如果您想要一个经常不稳定的模块,请在 建造。 一百
尝试使用
-U
参数再次运行mvn无效,我已尝试过
kursk@KURSK-PC /C/Users/kursk/.m2/repository/kursk/practice/ch07
$ ls -l
total 0
drwxr-xr-x 4 kursk Administ 0 Mar 8 15:06 simple-model2
drwxr-xr-x 3 kursk Administ 0 Mar 8 15:07 simple-parent2