Maven control version of transitive dependencies of Spring Boot - spring

I have a simple spring boot app that I am trying to add spring cloud consul to. Spring cloud consul relies on a newer version of spring boot. In my POM I have specified version 1.3.5.RELEASE for all my spring boot artifacts.
The problem is that, even though version 1.3.5 is specified for spring-boot-starter-web it still downloads dependencies with version 1.2.3
Is there a way to have maven get the 1.3.5.RELEASE for ALL spring boot artifacts, including transitive dependencies? I know I can explicitly list them all, but is there a better way?
Here is the POM depenency view from eclipse:

Yes, simple use correct parent:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.6.RELEASE</version>
<relativePath/>
</parent>
and remove versions from spring boot dependencies.

Related

Why spring.io generate pom without version?

I'm new to springboot and using spring.io to create project in order to create microservices.
When creating a project using spring.io website, a pom is created with all the relevant
dependencies but versions are not added.
Should I add the versions myself looking the maven repository jar (all jars include
versions on them)?
All dependencies (and configurations) are managed by Spring Boot. The parent of the project you generated with Spring Initializr has the parent set to spring-boot-starter-parent:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
The parent of spring-boot-starter-parent is spring-boot-dependencies which defines all dependency versions.
Therefore you don't need to specify any versions of the starter dependencies or their dependencies manually.
Please take a look at The Spring Boot Starter Parent on Baeldung for a quick overview.

Why does spring dependencies on Maven Central differ from actual local?

I am using spring-boot-starter-parent 2.3.9.RELEASE which according to Maven Central should give me spring-boot-starter-security 2.3.9.RELEASE which in turn should give me spring-security-config 5.3.8.RELEASE.
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.9.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
However, when I look at Eclipse I see spring-security-config 5.3.5.RELEASE. I dont understand why my local is not reflecting spring-security-config 5.3.8.RELEASE for this artifact even though spring boot starter parent and spring boot starter security (both parents of this) are correctly showing 2.3.9.RELEASE. Also I'm not sure I understand what "Managed from 5.3.8.RELEASE" means in the screenshot. Could someone assist ?
This means that an entry in your <dependencyManagement> section of the POM overrode the version.
This may be a direct entry or a BOM, which you recognise by <scope>import</scope>.

JHipster project with 4.13.3 and Maven integration QueryDSL for querying JPA

When generating a JHipster project with 4.13.3, and doing a Maven integration of QueryDSL (like described in http://www.querydsl.com/static/querydsl/4.1.3/reference/html_single/#d0e132), the Query types are not generated into target/generated-sources/java.
Before I used JHipster 4.10.x and it worked.
What changed? What I noticed with 4.13.3, that the pom.xml changed, for example the parent is not present any more, before it was:
<parent>
<artifactId>spring-boot-starter-parent</artifactId>
<groupId>org.springframework.boot</groupId>
<version>1.5.7.RELEASE</version>
<relativePath/>
</parent>
Now with JHipster 4.13.3 this is missing. I also had to define in the properties of the pom.xml
<querydsl.version>4.1.3</querydsl.version>
otherwise when doing a mvn clean install it throws an ERROR.
What to do to do a Maven integration of QueryDSL into a JHipster project with 4.13.3?
Cheers

How to override the managed version of dependencies in Spring Boot

Spring Boot allows us to change the Java version using:
<properties>
<java.version>1.8</java.version>
</properties>
Is there any property to change the Java EE version or spring version in my Spring Boot pom.xml?
Currently I override the managed version using:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
</dependency>
Is there a better way to do this, like just setting properties?
Spring Boot 1.2.3 gives you Spring 4.1.6 by default.
How can I force Spring Boot to give me 4.1.5 instead, just by setting properties?
This in your pom.xml should do it:
<properties>
<spring.version>4.1.5.RELEASE</spring.version>
</properties>
All straight from the docs.
Before you go overboard overriding versions of dependencies, heed this advise (from the link above):
Each Spring Boot release is designed and tested against a specific set of third-party dependencies. Overriding versions may cause compatibility issues.

Which spring-test jar version to use with Spring Integration

We are using Spring Integration version 2.2.0.RC2.
When running tests, the following exception is thrown:
java.lang.IncompatibleClassChangeError: org/springframework/core/type/classreading/AnnotationMetadataReadingVisitor
I understand this is because of a clash of Spring jars, likely due to the wrong version in the following maven dependency
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>3.2.2.RELEASE</version>
</dependency>
When using Spring Integration version 2.2.0.RC2, which version of spring-tests should be used? Furthermore, what is the best way to resolve these kind of Maven clashes in future - is there a listing of compatible versions of Spring jars?
Thanks
If you a do a mvn dependency:tree are there any org.springframework:spring-core libraries in there that are not at the expected levels?
Run that and make sure your spring version numbers are ALL consistent. Use dependencyManagement stanzas to ensure they're consistent.
This issue had the same symptoms.
We run a nightly build of SI against Spring 3.2.x; 3.1.3 is simply the minimum supported dep. To use a newer version of Spring, you can <exclude/> the transitive dependencies in your POM.

Resources