Skip to content

odrotbohm/spring-record-support

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 

Spring Record support (experimental)

This repository contains a tiny Spring extension that makes JDK 14 records work with Spring, most notably Spring MVC’s web binding and Spring Data. It achieves that by providing a custom BeanInfoFactory that’s ultimately responsible to create PropertyDescriptor instances via BeanUtils.getPropertyDescriptors(…), which Spring modules usually use to inspect types for all interactions with user code.

Usage

All you need to do is including the JAR in your JDK 14 project and enable the preview features (by using the --enable-preview flag).

<dependency>
  <groupId>de.odrotbohm.experiments</groupId>
  <artifactId>spring-record-support</artifactId>
  <version>0.0.1-SNAPSHOT</version>
</dependency>

Artifacts are available from the Spring snapshot repo:

<repositories>
  <repository>
    <id>spring-libs-snapshot</id>
    <url>https://repo.spring.io/libs-snapshot</url>
  </repository>
</repositories>

Find a sample of the usage of this in the spring-record-example folder using a record with Spring Data’s mapping infrastructure.

Outlook

This is not intended for production usage right now as it’s an experiment to see what it actually takes to make Spring Framework work with records. There are currently discussions going on to make a future JDK return PropertyDescriptor instances for records out of the box. That would prevent other frameworks (Hibernate, Thymeleaf etc.) from having to ship similar support. I.e. we might see the need for code like this to go away in a future JDK release.

About

Spring extension to make JDK 14's records work OOTB with Spring libraries

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages