This is a simple Spring Boot application demonstrating basic CRUD operations using MySQL as the database. The application includes an entity User
, a repository UserRepository
, and a RESTful controller MainController
exposing endpoints for adding users and retrieving all users.
Make sure you have the following installed:
- Java Development Kit (JDK)
- MySQL database on Aiven (Cloud) or local machine
-
Clone the repository:
git clone <repository-url>
-
Configure MySQL on Aiven
- DemoApplication.java: The entry point for the Spring Boot application.
- User.java: Entity class representing a user with
id
,name
, andemail
fields. - UserRepository.java: Interface extending
CrudRepository
for user data access operations. - MainController.java: RESTful controller providing endpoints for adding and retrieving users.
Run the DemoApplication.java
class as a Java application.
The application will start on localhost:8090
(specified in application.properties
).
You can change the port number in application.properties
if required.
-
GET /demo/all: Retrieve all users.
curl http://localhost:8080/demo/all
-
POST /demo/add: Add a new user. Provide
name
andemail
as request parameters.Invoke-WebRequest -Uri http://localhost:8090/demo/add -Method POST -Body @{ name = "Hardvan" email = "123@email.com" }