无法解析Maven依赖占位符,如何在项目侧不修改框架解决?
child-jar1 When Framework Uses Parent POM with ${revision} Let’s work through this issue—since you can’t modify any framework settings, here are actionable fixes you can apply directly in your my-project:
1. Define the revision Property in Your Project’s POM
Add the same revision property the framework uses to your project’s <properties> section. This lets Maven resolve the placeholder in child-jar1’s POM using your project’s property value:
<properties> <revision>2.0</revision> </properties>
When Maven processes your dependency on child-jar1, it will use this value to replace ${revision} in the framework’s parent POM reference, allowing it to locate the parent POM and resolve the child JAR correctly.
2. Import the Framework Parent POM via Dependency Management
Add the framework’s parent POM to your project’s <dependencyManagement> section with import scope. This tells Maven to pull in the parent POM’s metadata (including version info) before resolving your dependencies:
<dependencyManagement> <dependencies> <dependency> <groupId>my-company</groupId> <artifactId>framework-parent</artifactId> <version>2.0</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>
Once the parent POM is imported, Maven will have the necessary version details to resolve child-jar1 without struggling with the ${revision} placeholder.
3. Pass the revision Value via Command Line
If you prefer not to modify your POM at all, you can explicitly set the revision property when running your build command:
mvn clean install -Drevision=2.0
This forces Maven to use the specified value for all ${revision} placeholders encountered during the build, including those in the framework’s POM files.
All three approaches work without any changes to the framework’s setup—pick the one that fits your project’s build workflow best!
内容的提问来源于stack exchange,提问作者June2nd

