Coder Social home page Coder Social logo

murodin / spring-record-support Goto Github PK

View Code? Open in Web Editor NEW

This project forked from odrotbohm/spring-record-support

0.0 0.0 0.0 11 KB

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

License: Apache License 2.0

Java 100.00%

spring-record-support's Introduction

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.

spring-record-support's People

Contributors

odrotbohm avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.