This project showcases the powerful integration of Spring MVC with Java Persistence API (JPA), utilizing Hibernate for efficient Object-Relational Mapping (ORM). Now deployed on AWS using Elastic Beanstalk, EC2, RDS, IAM, VPC Security, and more.
- Seamless Backend Integration: Effortlessly manage and query data with a robust backend framework.
- Advanced AWS Deployment: Hosted on AWS using Elastic Beanstalk, EC2, and RDS, ensuring high availability and scalability.
- Core Entities:
- Instructor: Manage instructor details and associated courses.
- Address: Handle address information for instructors and courses.
- Course: Organize and maintain course offerings and their related entities.
- Database Schema Management: Leverage Liquibase to manage database versioning and migrations, ensuring smooth transitions during updates.
- API Testing: Utilize Postman as a client for testing API endpoints, making it easy to verify and validate the functionality of your application.
- Enhanced Security:
- Secure roles and permissions with IAM Roles.
- Use AWS Systems Manager Parameter Store for securely storing database credentials.
- Implement Spring Profiles for environment-specific configurations (dev, prod), improving security and maintainability.
- Docker Integration: Easily deploy using Docker with pre-configured containerization support.
- Scalable & Secure Architecture:
- Utilize VPC Security Groups to control network access.
- Route 53 Integration for a custom domain setup.
- Performance Optimization: Utilize caching, connection pooling, and optimized database queries for high efficiency.
- MVC Architecture: Utilize a clean and organized Model-View-Controller architecture for clear separation of concerns.
- Dynamic Web Pages: Render interactive and dynamic web pages with Thymeleaf.
- CRUD Operations: Perform Create, Read, Update, and Delete operations for Instructor, Address, and Course entities.
With this setup, you can efficiently build and maintain a robust, secure, and scalable application tailored to your data management needs!
- Features
- Prerequisites
- Getting Started
- Technologies
- Demo
- Docker
- AWS Deployment
- Deployment Process
- Security Enhancements
- Resources
To push your Docker image to Docker Hub, use the following command:
docker push your-docker-repo/spring-mvc-app:latest
The project is now deployed on AWS using the following services:
- Elastic Beanstalk: Automates the deployment process.
- EC2: Provides scalable computing resources.
- RDS (MySQL): Secure and managed database service.
- IAM Roles: Controls access permissions.
- VPC Security: Restricts network access.
- Route 53: Custom domain setup.
Run the following command to build the project:
mvn clean package -DskipTests
Add the following dependencies to build the project:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.awspring.cloud</groupId>
<artifactId>spring-cloud-aws-dependencies</artifactId>
<version>3.2.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependency>
<groupId>io.awspring.cloud</groupId>
<artifactId>spring-cloud-aws-starter-parameter-store</artifactId>
</dependency>
Use AWS Elastic Beanstalk CLI or AWS Management Console to upload the JAR file.
ew deploy --application-name my-spring-app --environment-name my-env --version-label v1 --source-bundle myapp.jar
Monitor the deployment logs on AWS Elastic Beanstalk to ensure successful deployment.
Access your deployed application at:
http://your-app-env.elasticbeanstalk.com
To associate a custom domain with your application:
- Purchase a domain from AWS Route 53.
- Create a new hosted zone in Route 53.
- Configure an A record to point to the Elastic Beanstalk environment.
- Update the domain settings to reflect the new changes.
- Verify the domain mapping works correctly.
- AWS Parameter Store for securely storing credentials.
- Spring Profiles (dev, prod) for environment-specific settings.
- Database credentials secured via AWS Systems Manager Parameter Store.
spring.config.import=aws-parameterstore:/config/instructor-db
Before you begin, ensure you have the following:
- Java Development Kit (JDK 11 or later) installed.
- Maven for dependency management.
- Postman for API testing.
- Docker installed for containerization.
- AWS CLI configured for deployment.
Generate a new Spring Boot project using Spring Initializr with:
- Project: Maven Project
- Language: Java
- Spring Boot: Latest stable version
- Packaging: Jar
- Dependencies: Spring Web, Spring Data JPA, Thymeleaf, Liquibase, MySQL Driver
Update application.properties
:
spring.liquibase.change-log=db/changelog/db_master_changelog.xml
# Use environment variables for security
database.url=jdbc:mysql://localhost:3307/mydb
database.username=root
database.password=shosh404@@
spring.datasource.url=${database.url}
spring.datasource.username=${database.username}
spring.datasource.password=${database.password}
Create entities for Instructor, Address, and Course, and define repository interfaces for each.
Develop services to handle business logic and controllers to manage HTTP requests.
Design templates for user interactions.
Verify API functionality with Postman by sending CRUD requests.
Start your Spring Boot application. The server will be available at: http://localhost:8082