Skip to content

Eustachekamala/Spring-Boot-Amazon-RDS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Boot RDS Demo

A Spring Boot web application that demonstrates integration with Amazon RDS (Relational Database Service) for managing products. This project showcases best practices for building Java applications with Spring Data JPA and MySQL databases.

Table of Contents

Project Overview

This application provides a RESTful API for managing products in a MySQL database hosted on AWS RDS. It demonstrates:

  • Spring Boot 4.0.2 with Java 21
  • Spring Data JPA for ORM (Object-Relational Mapping)
  • MySQL database connectivity
  • REST API design patterns
  • Hibernate configuration

Architecture

System Architecture

System Architecture

Tech Stack

Component Technology Version
Framework Spring Boot 4.0.2
Language Java 21
Database MySQL 8.0+
ORM Hibernate via Spring Data JPA Latest
Build Tool Maven 3.6+
Connector MySQL Connector/J Latest
Utils Lombok Latest

Prerequisites

Before you begin, ensure you have:

  • Java 21 or higher installed
  • Maven 3.6+ installed
  • MySQL Server 8.0+ running locally or on AWS RDS
  • Git for version control
  • An AWS Account (for cloud deployment)

🚀 Getting Started

1. Clone the Repository

git clone https://github.com/Eustachekamala/Spring-Boot-Amazon-RDS.git
cd spring-rds-demo

2. Configure Database Connection

Edit src/main/resources/application.yaml:

spring:
  datasource:
    url: jdbc:mysql://your-rds-endpoint:3306/your-database
    username: your-username
    password: your-password
    driver-class-name: com.mysql.cj.jdbc.Driver
  jpa:
    hibernate:
      ddl-auto: update
    show-sql: true

3. Build the Application

# Using Maven wrapper
./mvnw clean package

# Or using Maven
mvn clean package

4. Run the Application

# Using Maven
./mvnw spring-boot:run

# Or using Java directly
java -jar target/spring-rds-demo-0.0.1-SNAPSHOT.jar

The application will start on http://localhost:8080

API Endpoints

1. Create Product

Request:

POST /product
Content-Type: application/json

{
  "name": "Laptop",
  "description": "High-performance laptop",
  "price": 999.99,
  "quantity": 50
}

Response:

{
  "status": 200,
  "message": "Product created successfully"
}

2. Get All Products

Request:

GET /products

Response:

[
  {
    "id": 1,
    "name": "Laptop",
    "description": "High-performance laptop",
    "price": 999.99,
    "quantity": 50
  },
  {
    "id": 2,
    "name": "Mouse",
    "description": "Wireless mouse",
    "price": 29.99,
    "quantity": 200
  }
]

Key Configuration Options

  • ddl-auto: update - Automatically update database schema on startup
  • show-sql: true - Log SQL queries to console
  • dialect: MySQL8Dialect - Use MySQL 8.x specific features

AWS Deployment

Prerequisites for AWS Deployment

  1. RDS Instance Setup

    • Create MySQL RDS instance in AWS Console
    • Configure security groups to allow traffic
    • Create database and user credentials
    • Take note of the endpoint URL
  2. Update Configuration

    • Replace localhost with RDS endpoint
    • Use AWS Secrets Manager for sensitive credentials
    • Consider environment variables for deployment

Connection String Examples

Local MySQL

jdbc:mysql://localhost:3306/testdb?useSSL=false&serverTimezone=UTC

AWS RDS

jdbc:mysql://mydb.c9akciq32.us-east-1.rds.amazonaws.com:3306/testdb

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages