Repository
In this application, we have created Mongo Repository interface named EventRepo using @Repository Annotation for Handling CRUD operations in this application. It interacts with Database. This Connection extends to MongoRepository.
EventRepo.java:
package com.event.management.app.repo;
import org.springframework.data.mongodb.repository.MongoRepository;
import com.event.management.app.domain.EventRegistration;
public interface EventRepo extends MongoRepository<EventRegistration, String>{
}
Event Registration System using Spring Boot
Event Registration System plays an important role in the Event Management Business for tracking the Event related details and also we can adjust our time table also according to the events data. In this Article we will explain about the Event Registration System is works with a good example with related output images. First we create a beautiful home page in this page we provide a welcome message and there are two buttons. The Get Started button is used for redirecting the Event Registration page to Book the Slot and other one is Booked Slots button which is used for view the all registered event details.
Here we use Thymeleaf is a java library which is used for handle the render the dynamic data by using the Spring MVC pattern in the this Application. And we gather below event details include ticket and payment details. The Event Registration fields are Event Name, Date and Time, Address, vent Organizer Name, Phone Number, Email, Ticket Type, Total Price, Ticket Price, Quantity, Payment Method.
Ticket & Payment Information:
- Ticket Type
- VIP
- Student
- General
- Ticket Price
- VIP – 500
- Student – 100
- General – 300
- Payment Method
- Credit Card
- Debit Card
- UPI
- Online Banking
Prerequisites:
- Spring Boot Framework
- Thymeleaf
- MongoDB
- Spring MVC Pattern
- Bootstrap Framework
- Project Type is Gradle
- Spring Tool Suite IDE (STS)
Gradle Dependencies:
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-mongodb'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
Spring Initializr:
Using Spring Initializr we will will create our project structure.
- Here we have selected the Project type that is Gradle.
- Then we filled the Metadata of the Project that are: Group Id, Artifact Id, Name, Description, Java version.
- Also, we have added here all the required Gradle dependencies which we can see in the build.gradle file.
Project Folder Structure:
Database Connection:
Here we use MongoDB as a database. And below we provide the database connection logic with thymeleaf configuration for handling html files which are located in the template in the resource folder. For the database connection, we need three attribute values that are Host name, Port number of MongoDB.
# database properties
spring.data.mongodb.host=localhost
spring.data.mongodb.port=27017
spring.data.mongodb.database=eventdb
# thymeleaf configuration
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
Note: Here eventdb is the Database name, 27017 is the port number of MongoDB, and we have used Localhost for running the system.