4
我有一个多模块项目,并且正在使用父pom中的配置文件,这些配置文件中提到了特定的依赖关系。 这里的问题是,如果在子pom中,我重写了依赖项元素,并且提到父pom中的一个依赖项(在父pom中的配置文件中声明),那个特定依赖项的版本需要再次提及。如果在配置文件中提到maven子pom依赖关系,则不会从父pom依赖关系获取版本
E.g 父POM
<dependencies>
<dependency>
<groupId>com.mycode.apps</groupId>
<artifactId>jobs</artifactId>
<version>4</version>
</dependency>
</dependencies>
<profiles>
<profile>
<id>common-dependencies</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>com.mycode.apps</groupId>
<artifactId>dao</artifactId>
<version>4</version>
</dependency>
</dependencies>
</profile>
</profiles>
现在孩子的pom.xml
<dependencies>
<!--this one doesnt need a version specified -->
<dependency>
<groupId>com.mycode.apps</groupId>
<artifactId>jobs</artifactId>
</dependency>
<!--this one makes maven throw an error(if version is not specified) while compilation -->
<dependency>
<groupId>com.mycode.apps</groupId>
<artifactId>dao</artifactId>
</dependency>
</dependencies>
任何想法可能是错误的,我怎么能解决这个问题?
注:该配置文件被标记为activeByDefault