Spring Boot Blog REST API

repository·main·Indexed 18 days ago

https://github.com/rameshmf/springboot-blog-rest-api

A reference implementation of a Blog REST API using Spring Boot 3.2.1 and Spring Security 6+. Features include JWT 0.12.3 for stateless authentication, Spring Data JPA with MySQL, CRUD operations with pagination and sorting, DTO patterns, and Docker containerization for AWS deployment.

Tokens
607
Snippets
4
Records
6
Agent score
14%

What's inside springboot-blog-rest-api

  1. Overview of Spring Boot Blog REST API

    main
    This project is the source code for a complete Blog Application built using Spring Boot. It serves as a reference implementation for building real-time REST APIs. The project is specifically upgraded to use Spring Boot 3.2.1 and JWT 0.12.3, ensuring compatibility with modern Spring Security 6+ standards.
  2. Core Technologies and Learning Objectives

    main

    The project demonstrates the integration of several key technologies for building production-ready RESTful services:

    • Frameworks: Spring Boot 3+, Spring Security 6+
    • Security: JSON Web Token (JWT) for stateless authentication and role-based authorization (both In-memory and DB-based).
    • Data Access: Spring Data JPA (Hibernate) with MySQL database, including one-to-many and many-to-many mappings.
    • API Design: Implementation of CRUD operations, Pagination, Sorting, URI versioning strategies, and DTO (Data Transfer Object) patterns.
    • Validation & Error Handling: Spring Boot REST API validation and centralized exception handling.
    • DevOps & Deployment: Docker containerization and deployment to AWS Cloud.
  3. Build the project with Maven

    main

    To build the project, navigate to the root directory of the project and execute the build command. You can use a local Maven installation or the included Maven Wrapper (mvnw).

    # If Maven is installed on your machine
    mvn clean package
    
    # If Maven is NOT installed (using the wrapper)
    ./mvnw clean package
  4. Initialize roles in the database

    main

    After the application has started and tables are created, you must manually insert the required roles into the roles table to ensure proper authorization works. Use the following SQL statement:

    INSERT INTO `myblog.roles` VALUES (1,'ROLE_ADMIN'),(2,'ROLE_USER');