Maven多模块项目导入MicroProfile后依赖版本缺失问题求助
Let's tackle your two main issues: the missing dependency versions for cdi-api/javax.ws.rs-api and the "version contains an expression" warnings.
1. Fixing Missing Dependency Versions (Core Issue)
The root cause here is likely an incorrect import of the MicroProfile 1.3 BOM in your parent pom.xml. For Maven to recognize version values from a BOM, you must import it with <type>pom</type> and <scope>import</scope> inside <dependencyManagement>.
Step 1: Verify Parent POM's BOM Import
Ensure your root pom.xml has this exact configuration for the MicroProfile BOM:
<dependencyManagement> <dependencies> <!-- Import MicroProfile 1.3 BOM to manage dependency versions --> <dependency> <groupId>org.eclipse.microprofile</groupId> <artifactId>microprofile</artifactId> <version>1.3</version> <type>pom</type> <scope>import</scope> </dependency> <!-- Other managed dependencies go here --> </dependencies> </dependencyManagement>
Without <type>pom</type> and <scope>import</scope>, Maven won't pull in the version mappings from the BOM, which explains why it's asking for explicit versions in your war module.
Step 2: Simplify War Module Dependencies
In your hello-service-war/pom.xml, remove the <version> tag from cdi-api and javax.ws.rs-api dependencies. Maven will automatically pick the version from the imported BOM:
<dependencies> <dependency> <groupId>javax.enterprise</groupId> <artifactId>cdi-api</artifactId> <!-- Optional but recommended: use <scope>provided</scope> if deploying to a Java EE container --> <scope>provided</scope> </dependency> <dependency> <groupId>javax.ws.rs</groupId> <artifactId>javax.ws.rs-api</artifactId> <scope>provided</scope> </dependency> <!-- Other dependencies --> </dependencies>
2. Fixing "Version Contains an Expression" Warnings
Maven warns about ${project.parent.version} because it expects submodule versions to be either explicit constants or inherited implicitly from the parent (without declaring a <version> tag at all).
Fix Submodule POMs
For each submodule (hello-service-war, hello-service-ejb, hello-service-common), remove the <version> tag entirely. Since you're already inheriting from the parent POM via the <parent> section, the version will be pulled automatically:
<project> <parent> <groupId>com.pjain</groupId> <artifactId>hello-service</artifactId> <version>1.0.0-SNAPSHOT</version> <!-- Use your parent's actual version here --> <relativePath>../pom.xml</relativePath> </parent> <artifactId>hello-service-war</artifactId> <packaging>war</packaging> <!-- REMOVE THIS LINE: <version>${project.parent.version}</version> --> <!-- Rest of your submodule config --> </project>
Verify the Fix
Run this command from your war module directory to confirm dependencies are resolved correctly:
mvn dependency:tree
You should see javax.enterprise:cdi-api:jar:1.2 and javax.ws.rs:javax.ws.rs-api:jar:2.0.1 (or the exact versions defined in MicroProfile 1.3 BOM) listed without version conflicts.
内容的提问来源于stack exchange,提问作者Prateek Jain

