[英]Problem with dependencyManagement and dependency versions
I have problem with relations of pom, with dependency versions etc. Below my structure: My MAIN pom, which gives me the order to build of all projects我对 pom 的关系、依赖版本等有问题。在我的结构下面:我的 MAIN pom,它给了我构建所有项目的命令
<groupId>com.xyz</groupId>
<artifactId>yxz</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>xyz</name>
<modules>
<module>commons</module>
<module>projectA</module>
<module>ProjectB</module>
...
<module>ProjectX</module>
</modules>
COMMONS pom, it is designed to have common dependencies and properties, without any parent COMMONS pom,它被设计成有共同的依赖和属性,没有任何父
<groupId>com.xyz</groupId>
<artifactId>commons</artifactId>
<version>1.0-SNAPSHOT</version>
<name>commons</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.version>3.8.1</maven.compiler.version>
<java.version>11</java.version>
<lombok.version>1.18.24</lombok.version>
</properties>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
ProjectA pom, include commons dependency, with spring-boot in parent, ProjectA pom,包括公共依赖,父级为 spring-boot,
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.xyz</groupId>
<artifactId>projectA</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>projectA</name>
<properties>
<java.version>11</java.version>
<spring-cloud.version>2021.0.0</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>com.xyz</groupId>
<artifactId>commons</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
...
<dependency>
some dependencies from org.springframework.cloud
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
...
</build>
ProjectB pom, include commons dependency, with custom framework in parent, ProjectB pom,包括公共依赖项,在父项中具有自定义框架,
<parent>
<groupId>com.customframework</groupId>
<artifactId>custom.framework</artifactId>
<version>1.8.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.xyz</groupId>
<artifactId>projectB</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>projectB</name>
<properties>
<java.version>11</java.version>
<customeframework.feign.version>10.12</customeframework.feign.version>
</properties>
<dependencies>
<dependency>
<groupId>com.xyz</groupId>
<artifactId>commons</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
...
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-core</artifactId>
<version>11.8</version>
</dependency>
other feign dependecies with 11.8 version
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.customframework</groupId>
<artifactId>custom.framework.feign</artifactId>
<version>${customeframework.feign.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
...
</build>
When i build my all projects then:当我构建我的所有项目时:
What i want to do:我想做的事:
If you want to have the same dependencies in all modules then how about you define <dependencyManagement>
with all required BOMs and versions in one place (eg in commons module)?如果您想在所有模块中具有相同的依赖关系,那么您如何在一个地方(例如在 commons 模块中)定义具有所有必需 BOM 和版本的<dependencyManagement>
?
It won't bother the modules if they don't include some of the dependencies but it will make sure that all the modules have the same dependencyManagement rules.如果它们不包含某些依赖项,它不会打扰模块,但它会确保所有模块都具有相同的dependencyManagement 规则。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.