About • Features • How it works • Tech Stack • How to contribute • Author
An API written in Java with Spring Boot and Spring Data JPA to query for information on users. The database chosen is the in-memory H2 Database, for testing and demonstration purposes.
- Structure divided into Entities, Repositories and Controllers
- Pageable results
- Query parameters for filtering between values
- Classes and objects
- Encapsulation, getters and setters
- Object-Relational Mapping
Before getting started, you'll need to have the following tools installed on your machine:
In addition, you might also want an IDE to work with the code, like IntelliJ IDEA.
git clone https://github.com/alexbraga/jpa-repository.git
Navigate to the root directory of the project
cd jpa-repository
Build the project
mvn compile
Run the application
mvn spring-boot:run
- Alternatively, open the project with your preferred IDE and run
/src/main/java/com/example/jparepository/JpaRepositoryApplication.java
- The server will start at
localhost:8080
-
Get all users in the database:
GET
/users
-
Get all users, with pageable results:
GET
/users/page?page={page_number}&size={size}
-
Search users by salary range:
GET
/users/search-salary?minSalary={min_value}&maxSalary={max_value}
-
Search users by name:
GET
/users/search-name?name={user_name}
The following tools were used in the construction of the project:
- Spring Web
- Spring Data JPA
- H2 Database
See the file pom.xml
- Dependency Manager: Maven
- IDE: IntelliJ IDEA
- API Testing: Postman
- Fork the project
- Create a new branch with your changes:
git checkout -b my-amazing-feature
- Save your changes and create a commit message (in present tense) telling what you did:
git commit -m "Add my amazing feature"
- Submit your changes:
git push origin my-amazing-feature
- Create a pull request