Я получаю "сборка не может прочитать 1 проект" в сборке maven, потому что версии undefined
У меня родительский pom и интеграция-pom:
интеграция pom
<dependencies>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
</dependency>
<dependency>
<groupId>com.example</groupId>
<artifactId>example-model</artifactId>
</dependency>
</dependencies>
<parent>
<groupId>com.example</groupId>
<artifactId>example-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
родительский pom
<modules>
<module>../example-business</module>
<module>../example-integration</module>
<module>../example-model</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20131018</version>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>com.example</groupId>
<artifactId>example-model</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
Теперь, когда я сделаю чистую установку родителя, я получаю следующую ошибку:
[INFO] Scanning for projects...
Downloading: http://www.example.com/content/groups/mirror/com/example/example-parent/0.0.1-SNAPSHOT/maven-metadata.xml
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project com.example:example-integration:0.0.1-SNAPSHOT (D:\dev\workspaces\example-git\example\example-integration\pom.xml) has 3 errors
[ERROR] 'dependencies.dependency.version' for org.json:json:jar is missing. @ line 22, column 15
[ERROR] 'dependencies.dependency.version' for commons-httpclient:commons-httpclient:jar is missing. @ line 27, column 15
[ERROR] 'dependencies.dependency.version' for com.example:example-model:jar is missing. @ line 32, column 15
Но когда я посмотрю на Эффективный POM интеграционного пом, есть версия, написанная.
Так почему я не могу его построить?
Edit:
Вот фрагмент представления EFFECTIVE POM:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20131018</version>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>com.example</groupId>
<artifactId>example-model</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.example</groupId>
<artifactId>example-integration</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.example</groupId>
<artifactId>example-business</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20131018</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.example</groupId>
<artifactId>example-model</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.example</groupId>
<artifactId>example-business</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
Ответы
Ответ 1
Проблема связана с вашей структурой проекта и тем, как вы определили parent
в детских помпах.
Ваши дочерние модули фактически находятся в папках, которые находятся на одном уровне выше, чем ваш родительский pom, а не на одном уровне (судя по <module>../example-business</module>
). Когда maven пытается создать дочерние модули, он не может найти родительский pom, поскольку он недоступен в репозитории maven (он в настоящее время находится в процессе его создания, так что он еще не загружен).
Чтобы исправить это, вам просто нужно изменить определение parent
в дочерних помпах, чтобы определить реальный relativePath
в местоположении родительского пом, чтобы maven мог его найти. Поэтому измените его на следующее:
<parent>
<groupId>com.example</groupId>
<artifactId>example-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../name-of-folder-containing-parent-pom</relativePath>
</parent>
Очевидно, вам нужно будет изменить name-of-folder-containing-parent-pom
на то, что папка.
Ответ 2
Проверьте, почему зависимость от родителей не решается в вашем регионе.
Возможно, вам что-то не хватает в файле settings.xml, который находится в каталоге c: Users/name/.m2.
Проверьте правильность учетных данных, и вы добавили все ссылки на артефакты на случай, если они не являются общедоступными.