2017-12-18 7 views
-1

Ich bin neu in Maven, also frage ich mich, warum Maven tatsächlich die Eltern herunterladen wird.Maven Eltern POM download

Hier ist mein Beispielverzeichnis:

├── hazriq-module 
│ ├── document-generator 
│ |  ├── src folder 
│ |  └── pom.xml (document-generator) 
│ └── pom.xml (hazriq-module) 
└── pom.xml (hazriq-parent) 

Meine hazriq-parent .pom Datei:

<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> 

Mein hazriq-Modul .pom Datei:

<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> 

Mein Dokument- Generator .pom Datei:

<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> 

Wenn ich versuche, mvn install auszuführen:

$ 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 

Meine Fragen sind: 1. Warum wird Maven tatsächlich gehen und versuchen, die hazriq-parent herunterladen? von der repo.maven.apache.org? (Siehe die Ausgabe von meinem oben. 2. Wie kann ich mein Projekt erfolgreich erstellen?

Antwort

0

Warum sollte es nicht? Wenn Sie ein Modul erstellen, müssen alle übergeordneten Module rekursiv aufgelöst werden alle Abhängigkeiten.

Das heißt, die Artefakte haben entweder in der konfigurierten Remote-Repository (Maven Central von Standard) oder dem lokalen sein. Sie können ihn in Ihrem lokalen Repository, indem Sie eine mvn install

+0

Dies ist ein neues Repo, also habe ich noch kein Artefakt auf meinem Remote Repo. Ich habe 'mvn install' versucht, aber Sie können sehen, dass ich den Fehler in meiner Frage oben erwähnt habe. –

+0

@HazriqIshak müssen Sie zunächst eine 'mvn install' auf dem übergeordneten Element vornehmen. –

+0

Yup. Ich habe es getan, aber es wirft einen Fehler auf. Es ist in der Frage. –

0

hinzufügen können. der Grund, mein einziger Fehler ist wegen des Platzhalters in <version>

ich meine Eltern .pom geändert:

<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> 

Mein Modul .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> 

Mein Dokument-Generator .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> 

Ein gutes Buch zu diesem Thema: https://jeanchristophegay.com/maven-unique-version-multi-modules-build-en/

Verwandte Themen