Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

REST API with H2 Database using Spring Boot

This project is a REST API that connects to an H2 database using Spring Boot.

Features

  • RESTful API with CRUD operations
  • In-memory H2 database for testing and development
  • Spring Data JPA for database interaction
  • Maven for dependency management

Prerequisites

  • Java 11 or higher
  • Maven 3.6.3 or higher

Dependencies

The following dependencies are included in the pom.xml:

  • Spring Web
  • Spring Dev Tools
  • H2 Database
  • Spring Data JPA

Getting Started

Clone the Repository

git clone https://github.com/your-username/your-repo-name.git
cd your-repo-name

Build the Project

mvn clean install

Run the Application

mvn spring-boot:run

The application will start on http://localhost:8080.

Usage

API Endpoints

Here are some example endpoints for the USERS table:

  • GET /api/users - Retrieve all users
  • GET /api/users/{id} - Retrieve a specific user by ID
  • POST /api/users - Create a new user
  • PUT /api/users/{id} - Update an existing user by ID
  • DELETE /api/users/{id} - Delete a user by ID

Example Requests

GET /api/users

curl -X GET http://localhost:8080/api/users

POST /api/users

curl -X POST http://localhost:8080/api/users -H "Content-Type: application/json" -d '{"name": "New User", "email": "user@example.com"}'

H2 Console

You can access the H2 database console at http://localhost:8080/h2-console. Use the following settings:

  • JDBC URL: jdbc:h2:mem:testdb
  • Username: sa
  • Password: (leave blank)

Contributing

If you'd like to contribute, please fork the repository and use a feature branch. Pull requests are warmly welcome.

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Acknowledgements

  • Spring Boot documentation
  • H2 Database documentation

About

A Spring Boot REST API with CRUD operations using an in-memory H2 database and Spring Data JPA for managing user data. Ideal for quick setup and testing.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages