下面是我的parent-pom.xml :-
<groupId>com.example.parent</groupId>
<artifactId>example-parent</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<name>sample-parent</name>
<dependencyManagement>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers-bom</artifactId>
<version>1.19.1</version>
<type>pom</type>
</dependency>
</dependencyManagement>
在子 pom 中,我添加了以下依赖项:- 子 pom.xml
<groupId>com.example.child</groupId>
<artifactId>example-child</artifactId>
<version>1.0.0</version>
<name>sample-child</name>
<packaging>jar</packaging>
<parent>
<groupId>com.example.parent</groupId>
<artifactId>example-parent</artifactId>
<version>1.0.0</version>
</parent>
<dependencies>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>spock</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
但是,当我构建它时,出现以下错误:-
'dependencies.dependency.version' for org.testcontainers:testcontainers:jar is missing. @ com.example.child:sample-child:${revision}, C:\...\pom.xml, line 438, column 17
查看这里的各种帖子,它应该可以工作,但不知何故它在我的情况下不起作用。不知道我错过了什么。