This project demonstrates how to consume data from a REST API using Spring Boot. The application fetches post data from jsonplaceholder.typicode.com and displays it on both a JavaFX GUI and a web page.
- Fetches post data from the jsonplaceholder API
- Displays fetched data on a JavaFX GUI
- Displays fetched data on a web page
- Supports both desktop application and web application launch modes
To run this project, follow these steps:
-
Clone the repository to your local machine using the following command:
git clone https://github.com/your-username/Consuming-REST-API-with-SpringBoot.git
-
Navigate to the project directory:
cd Consuming-REST-API-with-SpringBoot
-
Depending on your preferred launch mode:
-
For Desktop Application:
- Uncomment the line
Application.launch(PostApp.class, args);
in theJavaFxAppLauncher
class. - Comment out the line
SpringApplication.run(ConsumingRestApiApplication.class, args);
in theJavafxSpringBootApplication
class. - Run the Spring Boot application.
- Uncomment the line
-
For Web Application:
- Comment out the line
Application.launch(PostApp.class, args);
in theJavaFxAppLauncher
class. - Uncomment the line
SpringApplication.run(ConsumingRestApiApplication.class, args);
in theJavafxSpringBootApplication
class. - Run the Spring Boot application.
- Access the web page at http://localhost:8080.
- Comment out the line
-
- Spring Boot
- JavaFX
- REST API
- Thymeleaf (for web page rendering)
|-- src
| |-- main
| |-- java
| | |-- com
| | |-- campipal
| | |-- campipal
| | |-- controller
| | | |-- PostController.java
| | |-- model
| | | |-- Post.java
| | |-- service
| | | |-- PostService.java
| | |-- CampipalApplication.java
| | |-- PostApp.java
| |
| |
| |-- resources
| |-- templates
| | |-- post.html
Contributions are welcome! If you find any issues or want to improve the project, feel free to create a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.
Feel free to copy and paste this Markdown code into your README file. Make sure to replace placeholders like `[your-username]` with the actual values and adjust any URLs as needed.