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.
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
| 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 |
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)
git clone https://github.com/Eustachekamala/Spring-Boot-Amazon-RDS.git
cd spring-rds-demoEdit 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# Using Maven wrapper
./mvnw clean package
# Or using Maven
mvn clean package# Using Maven
./mvnw spring-boot:run
# Or using Java directly
java -jar target/spring-rds-demo-0.0.1-SNAPSHOT.jarThe application will start on http://localhost:8080
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"
}Request:
GET /productsResponse:
[
{
"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
}
]ddl-auto: update- Automatically update database schema on startupshow-sql: true- Log SQL queries to consoledialect: MySQL8Dialect- Use MySQL 8.x specific features
-
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
-
Update Configuration
- Replace localhost with RDS endpoint
- Use AWS Secrets Manager for sensitive credentials
- Consider environment variables for deployment
jdbc:mysql://localhost:3306/testdb?useSSL=false&serverTimezone=UTC
jdbc:mysql://mydb.c9akciq32.us-east-1.rds.amazonaws.com:3306/testdb
