0
votes

I am following the Spring documentation Using Spring Boot without the parent POM. In my parent POM, I am defining an import dependency on spring-boot-dependencies in the dependenciesManagement section. In my child POM I then define a dependency on spring-boot-starter-jersey, not specifying any version. When I look at the dependency:tree, I see that all the jersey dependencies use the version specified in spring-boot-dependencies. All is well.

Now, in my child POM, I need to add another jersey dependency. In the spring-boot-dependencies POM, I see that a property jersey.version is defined. However, when I use ${jersey.version} in my child POM, the property is not defined.

Why is ${jersey.version} not available in the child POM?

Parent POM snippet:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <version>1.5.0.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

Child POM snippet:

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jersey</artifactId>
    </dependency>
    <dependency>
        <groupId>org.glassfish.jersey.media</groupId>
        <artifactId>jersey-media-sse</artifactId>
        <version>${jersey.version}</version>  <!-- error here -->
    </dependency>
</dependencies>

From spring-boot-dependencies-1.5.0.RELEASE.pom:

<properties>
    <jersey.version>2.25.1</jersey.version>
</properties>
1
you don't need provide version if dep in spring-boot-dependencies docs.spring.io/spring-boot/docs/current/reference/html/… - Georgy Gobozov
@Georgy: I need to add an additional dependency that is not in the spring boot dependencies, and wanted to use the same version as related artifacts in the spring boot dependencies. - rwfbc
ok I see, since dependency jersey-media-sse not in spring-boot-dependencies maven does not resolve version, it does for dependencies which in spring-boot-dependencies but not for others. I believe if you put spring-boot-dependencies as explicit parent - it would work. - Georgy Gobozov

1 Answers

0
votes

Properties are inherited only from parent POMs. This is stated in the maven documentation (unfortunately I can't find the reference anymore).