The Blog API is a Spring Boot application that provides CRUD operations for managing blog posts. It allows users to create, read, update, and delete blogs through a RESTful API.
- Create a new blog post
- Retrieve all blog posts
- Retrieve a blog post by ID
- Update an existing blog post
- Delete a blog post
- Java 17+
- Spring Boot (Spring Web, Spring Data JPA)
- Hibernate (ORM for database interactions)
- MySQL/PostgreSQL (or any relational database)
- Maven (for dependency management)
- Postman (for API testing)
Ensure you have the following installed:
- Java Development Kit (JDK 17 or later)
- Maven
- MySQL (or PostgreSQL, or any preferred relational database)
-
Clone the Repository
git clone https://github.com/Dhiraj706Sardar/Blog-Restful-API.git cd Blog-Restful-API -
Configure the Database Copy the
application.properties.examplefile and rename it toapplication.properties. Update it with your database credentials:spring.datasource.url=jdbc:mysql://localhost:3306/blogdb spring.datasource.username=your_db_username spring.datasource.password=your_db_password spring.jpa.hibernate.ddl-auto=update spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect
-
Build and Run the Application
mvn clean install mvn spring-boot:run
-
Access API Endpoints
- Create a Blog:
POST /blogs - Get All Blogs:
GET /blogs - Get Blog by ID:
GET /blogs/{id} - Update a Blog:
PUT /blogs/{id} - Delete a Blog:
DELETE /blogs/{id}
- Create a Blog:
You can use Postman to test the endpoints.
- Fork the repository
- Create a new feature branch (
git checkout -b feature-name) - Commit your changes (
git commit -m 'Add new feature') - Push to the branch (
git push origin feature-name) - Create a pull request
This project is licensed under the MIT License.
Happy Coding! 🚀