我有一个父项目pom看起来像这样:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.sss.it.cf</groupId>
<artifactId>cf-tenant-prov</artifactId>
<version>3.3.0-SNAPSHOT</version>
</parent>
<groupId>com.sss.it.cf</groupId>
<artifactId>cf-tenant-prov.parent</artifactId>
<version>3.3.0-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
<liquibase.version>3.1.1</liquibase.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<postgresql.version>42.2.5</postgresql.version>
<spring.security.jwt.version>1.0.9.RELEASE</spring.security.jwt.version>
<spring.security.oauth2.version>2.0.15.RELEASE</spring.security.oauth2.version>
<iaik.iaik_jce.version>5.22</iaik.iaik_jce.version>
</properties>
<modules>
<module>cf-tenant-prov.initdb</module>
<module>cf-tenant-prov.router</module>
<module>cf-tenant-prov.common</module>
<module>cf-tenant-prov.integration</module>
<module>cf-tenant-prov.dao</module>
<module>cf-tenant-prov.messaging</module>
<module>cf-tenant-prov.service</module>
<module>cf-tenant-prov.web</module>
<module>cf-tenant-prov.assembly</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.1.1.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<version>${powermock-api-mockito2.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>${powermock-module-junit4.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>
该项目中的模块具有以下pom:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>cf-tenant-prov.parent</artifactId>
<groupId>com.sss.it.cf</groupId>
<version>3.2.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cf-tenant-prov.common</artifactId>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>iaik</groupId>
<artifactId>iaik_jce</artifactId>
<version>${iaik.iaik_jce.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
</dependency>
</dependencies>
</project>
这可以在我的机器上成功构建,但是在jenkins构建中,如果有人克隆了这个git并进行了maven构建,我将收到如下错误:
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] 'dependencies.dependency.version' for iaik:iaik_jce:jar must be a valid version but is '${iaik.iaik_jce.version}'. @ com.sap.it.cf:cf-tenant-prov.common:
[unknown-version], C:\Users\I501807\git\hcisvcprov\cf-tenant-prov.parent\cf-tenant-prov.common\pom.xml
<file:///C:/Users/XXXXXX/git/hcisvcprov/cf-tenant-prov.parent/cf-tenant-prov.common/pom.xml> , line 33, column 22
所有版本。
当这些属性位于单独的小球中时,这是较早的工作。
我只是将这些依赖关系上移了一层,以使它们不会在每个pom文件中重复出现。
答案 0 :(得分:0)
您的父母说它是3.3.0-SNAPSHOT
版。但是您的模块引用的是版本3.2.0-SNAPSHOT
。这些属性是否已经包含在3.2.0-SNAPSHOT中,或者您只是忘记增加模块POM中的版本?
答案 1 :(得分:0)
您的父pom.xml应该具有所有依赖项(每个依赖项 将在子模块中使用)
<dependencyManagement>
.
.
</dependencyManagement>
包括它们的版本(您可以使用属性或直接指定版本),然后可以在任何子模块中使用这些依赖项,甚至无需指定版本。
父pom.xml应该看起来像:-
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.sss.it.cf</groupId>
<artifactId>cf-tenant-prov</artifactId>
<version>3.3.0-SNAPSHOT</version>
</parent>
<groupId>com.sss.it.cf</groupId>
<artifactId>cf-tenant-prov.parent</artifactId>
<version>3.3.0-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
<liquibase.version>3.1.1</liquibase.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<postgresql.version>42.2.5</postgresql.version>
<spring.security.jwt.version>1.0.9.RELEASE</spring.security.jwt.version>
<spring.security.oauth2.version>2.0.15.RELEASE</spring.security.oauth2.version>
<iaik.iaik_jce.version>5.22</iaik.iaik_jce.version>
</properties>
<modules>
<module>cf-tenant-prov.initdb</module>
<module>cf-tenant-prov.router</module>
<module>cf-tenant-prov.common</module>
<module>cf-tenant-prov.integration</module>
<module>cf-tenant-prov.dao</module>
<module>cf-tenant-prov.messaging</module>
<module>cf-tenant-prov.service</module>
<module>cf-tenant-prov.web</module>
<module>cf-tenant-prov.assembly</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.1.1.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<version>${powermock-api-mockito2.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>${powermock-module-junit4.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>iaik</groupId>
<artifactId>iaik_jce</artifactId>
<version>${iaik.iaik_jce.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
子模块应该看起来像:-
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>cf-tenant-prov.parent</artifactId>
<groupId>com.sss.it.cf</groupId>
<version>3.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cf-tenant-prov.common</artifactId>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</dependency>
<dependency>
<groupId>iaik</groupId>
<artifactId>iaik_jce</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>
</dependencies>
</project>