In this tutorial you will learn how to call a REST API using the JDK's Http Client. In this example you will call a public REST API and build out an entire CRUD service complete with tests using JUnit 5.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
- Java 17 or higher
- Maven
- Docker (optional)
- IntelliJ IDEA (optional)
- Postman (optional)
A step by step series of examples that tell you how to get a development environment running.
- Clone the repository
git clone https://github.com/OmerJuve2023/http-client.git
- Change into the project directory
cd JpsOwnStarted
- Build the project
mvn clean install
- Run the project
mvn spring-boot:run
- Open your browser and navigate to
http://localhost:8080/api/posts
To run the tests, execute the following command:
mvn test
- Build the Docker image
docker build -t http-client
- Run the Docker container
docker run -p 8080:8080 http-client
- Build the native image
mvn -Pnative spring-boot:build-image
- Run the native image
docker run -p 8080:8080 http-client
- OmerJuve2023 - OmerJuve2023