Giter VIP home page Giter VIP logo

manasranjanmohanta / springboot-json-infinite-recursion Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 19 KB

This Spring Boot application demonstrates how to prevent infinite recursion when fetching JPA entities. Using the H2 in-memory database, this project illustrates proper configuration and usage of Jackson annotations such as `@JsonManagedReference` and `@JsonBackReference` to manage bidirectional relationships and avoid serialization issues.

Java 98.11% Dockerfile 1.89%

springboot-json-infinite-recursion's Introduction

springboot-json-infinite-recursion

Features

  • Spring Boot: Simplifies the development process and provides a robust framework for building enterprise-level applications.
  • H2 Database: An in-memory database used for simplicity and ease of demonstration.
  • JPA/Hibernate: Manages the persistence layer and entity relationships.
  • Jackson Annotations: Handles JSON serialization and prevents infinite recursion with @JsonManagedReference and @JsonBackReference.

How to Run

  1. Clone the repository:
    git clone https://github.com/manasranjanmohanta/springboot-json-infinite-recursion.git
  2. Navigate to the project directory:
    cd springboot-json-infinite-recursion
  3. Build and run the application:
    ./mvnw spring-boot:run
  4. Access the application:
    • The application will start on http://localhost:8080.
    • Use the provided endpoints to interact with the entities and see how infinite recursion is prevented during JSON serialization.

Endpoints

  • /students: Fetch and create student entities.
  • /classes: Fetch and create class entities.

Technologies Used

  • Spring Boot
  • Spring Data JPA
  • H2 Database
  • Jackson

Example JSON Request

{
    "id": 2,
    "name": "prangya",
    "aClassEntity": {
        "id": 1
    }
}
  • You can check you persistent data at http://localhost:8080/h2-console

springboot-json-infinite-recursion's People

Contributors

manasranjanmohanta avatar

Watchers

 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.