This is a Blogging web application built using Spring Boot, REST API, JPA, MySQL, and API testing with Postman. The application provides CRUD operations for managing posts and comments. There are two main controllers: Posts and Comments, each offering functionalities to add, retrieve, update, and delete posts/comments.
- Spring Boot
- REST API
- Spring Boot
- JPA (Java Persistence API)
- MySQL
- Postman
-
Posts Controller:
- Create a new post
- Retrieve all posts
- Retrieve a specific post by ID
- Update an existing post
- Delete a post
-
Comments Controller:
- Add a comment to a specific post
- Retrieve all comments for a specific post
- Retrieve a specific comment by ID
- Update an existing comment
- Delete a comment
- Clone the repository:
git clone https://github.com/nikunjpansari/Blogging-Application
- Import project into IDE:
- Import the project into your preferred IDE (Eclipse, IntelliJ IDEA, etc.).
- Configure MySQL database:
- Create a MySQL database named
blog_app
. - Update
application.properties
with your database configuration.
- Create a MySQL database named
- Run the application:
- Run the
BlogAppApplication.java
class to start the Spring Boot application.
- Run the
- Access the application at
http://localhost:8080
. - Use Postman or any other API client to interact with the endpoints.
- API documentation can be accessed at
http://localhost:8080/swagger-ui.html
.
- Method: GET
- URL:
/api/posts
- Description: Retrieves all posts.
- Method: GET
- URL:
/api/posts/{id}
- Description: Retrieves a specific post by its ID.
- Method: POST
- URL:
/api/posts
- Description: Creates a new post.
- Method: PUT
- URL:
/api/posts/{id}
- Description: Updates an existing post identified by its ID.
- Method: DELETE
- URL:
/api/posts/{id}
- Description: Deletes a post identified by its ID.
- Method: GET
- URL:
/api/posts/{postId}/comments
- Description: Retrieves all comments associated with a specific post.
- Method: GET
- URL:
/api/posts/{postId}/comments/{commentId}
- Description: Retrieves a specific comment by its ID, associated with a specific post.
- Method: POST
- URL:
/api/posts/{postId}/comments
- Description: Adds a new comment to a specific post.
- Method: PUT
- URL:
/api/posts/{postId}/comments/{commentId}
- Description: Updates an existing comment identified by its ID, associated with a specific post.
- Method: DELETE
- URL:
/api/posts/{postId}/comments/{commentId}
- Description: Deletes a comment identified by its ID, associated with a specific post.
- Import the Postman collection provided in the
postman
directory. - Run the collection to test the API endpoints.