I'm new to Maven, so I'm wondering why Maven will actually download the parent.
Here is my sample directory:
select to_char(9876.23 , 'fm999990.00') from dual;
My hazriq-parent .pom file:
├── hazriq-module
│ ├── document-generator
│ | ├── src folder
│ | └── pom.xml (document-generator)
│ └── pom.xml (hazriq-module)
└── pom.xml (hazriq-parent)
My hazriq-module .pom file:
<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>
<groupId>com.hazriq</groupId>
<artifactId>hazriq-parent</artifactId>
<version>${hazriq.verion}</version>
<packaging>pom</packaging>
<properties>
<hazriq.verion>1.0.0</hazriq.verion>
</properties>
<modules>
<module>hazriq-module</module>
</modules>
</project>
My document-generator .pom file:
<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.hazriq</groupId>
<artifactId>hazriq-parent</artifactId>
<version>1.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>hazriq-module</artifactId>
<name>hazriq-module</name>
<packaging>pom</packaging>
<version>${hazriq.verion}</version>
<modules>
<module>document-generator</module>
</modules>
</project>
When I try to run <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.hazriq</groupId>
<artifactId>hazriq-module</artifactId>
<version>1.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>com.hazriq.hazriq-module</groupId>
<artifactId>document-generator</artifactId>
<dependencies>
...
</dependencies>
:
mvn install
My questions are:
1. Why will Maven actually go and try to download the $ mvn install
[INFO] Scanning for projects...
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project com.hazriq:hazriq-module:${hazriq.verion} (C:\development\hzrqmvn\hazriq-module\pom.xml) has 1 error
[ERROR] Non-resolvable parent POM: Failure to find com.hazriq:hazriq-parent:pom:1.0.0 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted
until the update interval of central has elapsed or updates are forced and 'parent.relativePath' points at wrong local POM @ line 3, column 10 -> [Help 2]
[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/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException
? from the hazriq-parent
? (Refer to the output of my repo.maven.apache.org
above.
2. How can I successfully build my project?
答案 0 :(得分:0)
为什么不呢?如果构建模块,则必须以递归方式解析其所有父模块。所有依赖项也是如此。
这意味着这些人工制品必须位于配置的远程存储库(默认为Maven Central)或本地存储库中。您可以通过执行mvn install
将其添加到本地存储库。
答案 1 :(得分:0)
我失败的原因是因为<version>
中的占位符。
我将我的父母.pom改为:
<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>
<groupId>com.hazriq</groupId>
<artifactId>hazriq-parent</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<modules>
<module>hazriq-module</module>
</modules>
</project>
我的模块.pom:
<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.hazriq</groupId>
<artifactId>hazriq-parent</artifactId>
<version>1.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>hazriq-module</artifactId>
<name>hazriq-module</name>
<packaging>pom</packaging>
<version>1.0.0</version>
<modules>
<module>document-generator</module>
</modules>
</project>
我的文档生成器.pom:
<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.hazriq</groupId>
<artifactId>hazriq-module</artifactId>
<version>1.0.0</version>
</parent>
<groupId>com.hazriq.hazriq-module</groupId>
<artifactId>document-generator</artifactId>
</project>
关于这个问题的好读物:https://jeanchristophegay.com/maven-unique-version-multi-modules-build-en/