M
M
Mira Roosevelt2021-10-22 00:53:49
Maven
Mira Roosevelt, 2021-10-22 00:53:49

Maven and legacy dependencies. How to set the correct version?

Hello.
At work, there is a large long-term service based on Java 11 and Spring Boot 2.1
. In the next revision, it was necessary to start going to other services that had not previously been integrated into.
I chose between RestTemplate and WebClient the latter in view of its relevance.

To locally raise a working project is another task - to collect all the databases and systems where it already goes and wait until network access is issued.
To speed up the development, I created my own new local project, tested and transferred the new code to the working project of the service.
And here a surprise came out during compilation - some functions of the following classes were marked as non-existent:

  • import org.springframework.http.HttpHeaders ; ( spring-web artifact )
  • import reactor.netty.http.client.HttpClient ; ( reactor-netty artifact )


Did it right away:
  • mvn clean
  • reloaded project dependencies
  • mvn install
  • cleared the Intellij IDEA cache with unloading the project and restarting the IDE

None of this helped.

To use the WebClient, you need to include a single spring-boot-starter-webflux artifact .
But it turned out that artifacts are automatically pulled up:
  • spring-webflux
  • reactor netty


When I compared the version of these artifacts (including spring-web ) in the working project and my test one, they differed, in my project the versions were an order of magnitude higher.
I assumed that this is due to the fact that the version is not explicitly specified under the spring-boot-starter-webflux artifact and the old one is pulled up based on the slightly outdated spring-boot-starter-parent .
I explicitly specified the latest version of spring-boot-starter-webflux in the pom - it did not help, spring-webflux and reactor-netty dependencies remained outdated. spring-web , spring-webflux

and reactor -netty artifactsare not specified anywhere in the project in any pom.
I set them explicitly with the latest versions indicated, and the project was successfully compiled after that.

On the company's infrastructure, the service was once again run for tests, the Docker image was assembled, and the installation process on the server began.
And here again there is an error about the lack of used functions in the two classes previously mentioned.
I don't understand how Maven pulls the old version of artifacts when a specific version is already set in pom.xml.
Set versions in pom in brackets (eg [0.0.7] instead of 0.0.7) - didn't help either.

Maybe someone has already encountered this or knows how else you can force Maven to pull the latest / specified versions of artifacts?
Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
BorLaze, 2021-10-22
@MRoose

Try excluding updated modules from spring dependencies.
More or less like this:

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.tomcat</groupId>
                    <artifactId>tomcat-jdbc</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.hibernate</groupId>
                    <artifactId>hibernate-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.hibernate</groupId>
                    <artifactId>hibernate-entitymanager</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question