我们目前为所有项目(库和微服务)配置了此物料清单 (bom)
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</path>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
</path>
<path>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
...
我们有一个父 pom,在其中定义包含此 bom 的所有微服务的常见行为。
<dependencyManagement>
<dependencies>
<dependency>
<groupId>nl.bro</groupId>
<artifactId>jakarta.bro-bill-off-material</artifactId>
<version>${bro-bill-off-material.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
...
在文件中我们定义了 build.plugins.plugin
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</path>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
</path>
<path>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
请注意,版本缺失,因为我们在 bom 中定义了版本。我希望当我们让微服务项目从这个父项目派生时,maven 会接受这个。
然而这似乎不起作用。我们收到一条错误消息:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile (default-compile) on project jakarta.common-shared: Resolution of annotationProcessorPath dependencies failed: version can neither be null,
empty nor blank -> [Help 1]
这让我觉得很奇怪。为什么我必须重新定义 MapStruct、Lombok 或 Hibernate modelgen 的版本?对依赖项进行集中版本控制不是物料清单的本质吗?