Maven use compile dependency instead of updates

Viewed 28

I am not sure if I am framing this correctly I am using following spring-boot-starter-data-elasticsearch. As you can see the version is 2.5.7.

<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-elasticsearch -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
    <version>2.5.7</version>
</dependency>

As you can see there are 2 compile dependencies. One is spring-boot-starter and another is spring-data-elastic-search. For spring-data-elastic-search compile dependency, I want to use 4.2.7 instead of updated version 4.4.2. But, no matter what I do it always picks up version 4.4.2

Is there a way to use the version needed instead of the updated version? Same with internal dependency.

For example since spring-data-elastic-search is 4.4.2, I want internal dependency like rest-high-level-client to follow the actual version instead of updated version.

1 Answers

You should:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter</artifactId>
    <version>2.5.7</version>
    <exclusions>
        <exclusion>
            <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
            <groupId>org.springframework.boot</groupId>
        </exclusion>
    </exclusions>
</dependency>

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
    <version>4.2.7</version>
</dependency>
Related