Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
824 views
in Technique[技术] by (71.8m points)

maven 2 - Maven2 cannot find parent from relative path

I'm trying to use Maven2 but my child projects cannot find the parent project.

Directory structure is as follows:

--parent
  --pom.xml
--child
  --pom.xml

Child pom.xml file looks like:

<parent>
    <groupId>com.mycompany.app</groupId>
    <artifactId>myapp</artifactId>
    <version>${app.version}</version>
    <relativePath>.../parent/pom.xml</relativePath>
</parent>

However when I use maven it doesn't even seem to look in the relative path, it seems to try and download it from the maven repository. It's obviously not in the repo. I want it to look at the relative path. What am I doing wrong? Here's the error message:

[INFO] Scanning for projects...
Downloading: http://repo1.maven.org/maven2/com/mycompany/app/myapp/${app.version}/myapp-
${app.version}.pom
[INFO] Unable to find resource 'com.mycompany.app:myapp:pom:${app.version}' in reposit
ory central (http://repo1.maven.org/maven2)
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).


Project ID: null:web:jar:null

Reason: Cannot find parent: com.mycompany.app:myapp for project: null:web:jar:null for
 project null:web:jar:null
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can't use a property for the parent version - it must match. At the moment this is required for the build to be reproducible at a later date. A number of people are tracking this on issue https://issues.apache.org/jira/browse/MNG-624


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...