4

I have tried to figure out which version of spring-data-jdbc to use with Spring Boot 1.5.20.RELEASE (= Spring Framework 4.3.23.RELEASE) - but I can't find that info anywhere.

Is it because spring-data-jdbc only work with Spring Boot 2.x / Spring Framework 5.x?

Specifically I want to use @Query, @EnableJdbcRepositories, etc.

When I look at the release notes for Spring Data Ingalls SR20 (the release train that matches Boot 1.5.20.RELEASE / Framework 4.3.23.RELEASE) it looks like spring-data-jdbc is only supported in Lovelace (Boot 2.x and Framework 5.x): https://spring.io/blog/2019/04/10/spring-data-lovelace-sr6-kay-sr14-ingalls-sr20-released

EDIT & ANSWER: As per comment from @JensSchauder: spring-data-jdbc is a (fairly) new project created from scratch. There is no way to use it with Spring Framework 4.

Rasmus Lund
  • 137
  • 7

1 Answers1

2

If you look at the spring-data-jdbc pom.xml it uses spring-data-parent to manage Spring Framework version by defining and applying spring.version property. You must ensure that this Spring Framework version is compatible with whatever version you are using.

The first available spring-data-jdbc:1.0.0.RELEASE version uses spring-data-parent:2.1.0.RELEASE parent which requires Spring Framework 5.1:

<spring>5.1.0.RELEASE</spring> 

It's not be recommended to use spring-data-jdbc with lower Spring Framework version. Since Spring Boot 1.5.X uses Spring Framework 4.X the answer would be no.

Karol Dowbecki
  • 43,645
  • 9
  • 78
  • 111
  • So no way of using anything like `@Query` and `@EnableJdbcRepositories` with JDBC repositories unless we upgrade to Spring Framework 5.1.x? I was hoping the `spring-data-jdbc` had just been renamed or extracted from another module, or something similar... – Rasmus Lund May 24 '19 at 11:44
  • @RasmusLund Are you using Maven or Gradle? You should be using the spring-boot-starter-jdbc dependency. Spring Boot 1.x will then pull in the spring-jdbc package rather than spring-data-jdbc. – Gimby May 24 '19 at 11:52
  • @Gimby ...but that will just give me access to the "old" JDBC support stuff like JdbcTemplate - and not any Spring Data specific support - or?? – Rasmus Lund May 24 '19 at 11:56
  • @RasmusLund then you likely need spring-boot-starter-data-jpa. The point is: use starters. – Gimby May 24 '19 at 12:14
  • @Gimby I don't want JPA - I want JDBC :-/ – Rasmus Lund May 24 '19 at 12:35
  • 2
    @RasmusLund spring-data-jdbc is a (fairly) new project created from scratch. There is no way to use it with Spring Framework 4 and there is no "old version" or "predecessor" – Jens Schauder May 24 '19 at 12:48