Maven父pom变量未解析
我有以下POM结构:
./foobar-common/pom.xml ./abc-window/pom.xml ./abc-datasource/pom.xml
abc-window pom.xml都如下:
4.0.0 hu.abc.ringcore abc-window jar 1.0-SNAPSHOT abc-window ../foobar-common/pom.xml hu.abc.ringcore foobar-common 1.0 junit junit ${junit.version} test hu.abc.ringcore abc-datasource ${project.version} org.apache.maven.plugins maven-source-plugin 2.2.1 jar package org.apache.maven.plugins maven-eclipse-plugin 2.9 true true
abc-datasource pom.xml如下:
4.0.0 hu.abc.ringcore abc-datasource jar 1.0-SNAPSHOT abc-datasource ../foobar-common/pom.xml hu.abc.ringcore foobar-common 1.0 junit junit ${junit.version} test org.apache.commons commons-lang3 ${commons-lang3.version} hu.abc.ringcore abc-base ${project.version} hu.abc.ringcore abc-event ${project.version} hu.abc.ringcore abc-variable ${project.version} hu.abc.ringcore abc-variableintf ${project.version} hu.foobar.ring RateSorszamIntf ${ringcore-services.version} org.apache.maven.plugins maven-source-plugin 2.2.1 jar package org.apache.maven.plugins maven-eclipse-plugin 2.9 true true
foobar-common pom.xml如下:
4.0.0 Maven Default Project hu.foobar.ringcore foobar-common 1.0 pom UTF-8 4.10 3.1.2.RELEASE 2.0.6.RELEASE 1.1.1 1.6.1 6.0 3.0 1.3.4-SNAPSHOT 3.1
我的问题是,如果我在abc-datasource
执行mvn install
,则会按预期从父pom属性中提取依赖项版本。 但是如果我从引用abc-datasource
abc-window
mvn install
然后版本没有解析,我得到:
[ERROR] Failed to execute goal on project abc-window: Could not resolve dependencies for project hu.abc.ringcore:abc-window:jar:1.0-SNAPSHOT: Failed to collect dependencies for [junit:junit:jar:4.10 (test), hu.abc.ringcore:abc-datasource:jar:1.0-SNAPSHOT (compile)]: Failed to read artifact descriptor for org.apache.commons:commons-lang3:jar:${commons-lang3.version}: Could not transfer artifact org.apache.commons:commons-lang3:pom:${commons-lang3.version} from/to central (http://repo.maven.apache.org/maven2): IllegalArgumentException: Illegal character in path at index 70: http://repo.maven.apache.org/maven2/org/apache/commons/commons-lang3/${commons-lang3.version}/commons-lang3-${commons-lang3.version}.pom
两个项目都有相同的父pom,所以为什么它不起作用..?
在父pom中使用dependencyManagment
junit junit ${junit.version} org.apache.commons commons-lang3 ${commons-lang3.version}
添加父pom中的所有版本,并在子项中使用没有版本的依赖项
编辑
/pom.xml <-parent pom /abc-window/pom.xml <-child module /abc-datasource/pom.xml <-child module
和父pom应该包含
... abc-datasource abc-window ... ...
abc窗口中的父级列为:
../foobar-common/pom.xml hu.abc.ringcore foobar-common 1.0
abc-datasource中的父级列为:
../foobar-common/pom.xml hu.ratesoft.ringcore foobar-common 1.0
所以,他们没有相同的groupId。