Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jevin31/spring-boot-rest-api
This is a simple demo of how to create a REST API using Spring Boot, PostgreSQL, and JPA
https://github.com/jevin31/spring-boot-rest-api
java maven postgresql postmen springboot
Last synced: 10 days ago
JSON representation
This is a simple demo of how to create a REST API using Spring Boot, PostgreSQL, and JPA
- Host: GitHub
- URL: https://github.com/jevin31/spring-boot-rest-api
- Owner: jevin31
- License: mit
- Created: 2024-10-24T09:14:41.000Z (13 days ago)
- Default Branch: main
- Last Pushed: 2024-10-24T10:54:51.000Z (13 days ago)
- Last Synced: 2024-10-25T06:57:39.989Z (12 days ago)
- Topics: java, maven, postgresql, postmen, springboot
- Language: Java
- Homepage:
- Size: 29.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Spring Boot REST API with PostgreSQL
This project demonstrates how to create a simple REST API using Spring Boot, PostgreSQL, and JPA. The API allows for basic CRUD (Create, Read, Update, Delete) operations on a product entity.
## Table of Contents
- [Technologies Used](#technologies-used)
- [Installation](#installation)
- [Usage](#usage)
- [API Endpoints](#api-endpoints)
- [License](#license)## Technologies Used
- **Java**: 21
- **Spring Boot**: Latest version
- **PostgreSQL**: Database
- **Maven**: Project management and build tool
- **Eclipse**: IDE for Java development## Installation
1. **Clone the Repository**:
```bash
git clone https://github.com/yourusername/springapi.git
cd springapi
2. **Create PostgreSQL Database**:Open your PostgreSQL client and create a new database.
```sql
CREATE DATABASE springapidb;4. **Configure Application Properties**:
Update the src/main/resources/application.properties file with your PostgreSQL database credentials.
```java
spring.datasource.url=jdbc:postgresql://localhost:5432/springapidb
spring.datasource.username=your_postgresql_username
spring.datasource.password=your_postgresql_password
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true6. **Build the Project**:
Make sure you have Maven installed. Run the following command in your project directory.
```bash
mvn clean install
8. **Run the Application**:You can run the application from your IDE (Eclipse) or use the command line.
```bash
mvn spring-boot:run## Usage
Once the application is running, you can interact with the API using a tool like Postman or Curl.## API Endpoints
Create a Product (POST):URL: `http://localhost:8080/api/v1/products`
Request Body (JSON):
```json
{
"name": "Product 1",
"price": 100.0,
"quantity": 10
}
```Get All Products (GET):
URL: `http://localhost:8080/api/v1/products`
Get a Product by ID (GET):
URL: `http://localhost:8080/api/v1/products/{id}`
Delete a Product (DELETE):
URL: `http://localhost:8080/api/v1/products/{id}`
## License
This project is licensed under the MIT License - see the LICENSE file for details.