A simple RESTful web service built using Spring Boot.
This project demonstrates a basic Spring Boot application that provides a REST API. It includes a simple /greeting
endpoint that returns a greeting message.
- RESTful API with Spring Boot
- Dockerized for easy deployment
- Configurable default greeting message
- Java 21
- Spring Boot 3.3.3
- Maven 3.9.2
- Docker
- Java 21 installed on your machine
- Maven 3.8+ installed
- Docker installed
git clone https://github.com/your-username/spring-rest-service.git
cd spring-rest-service
mvn clean package
This will compile the project and generate a .jar file inside the target/ directory.
mvn spring-boot:run
This will start the application on http://localhost:8080.
You can access the greeting endpoint via the following URL:
http://localhost:8080/greeting
You can also provide a name as a query parameter:
http://localhost:8080/greeting?name=YourName
This project is Dockerized for easy container deployment.
To build the Docker image:
docker build -t spring-rest-service .
To run the application in a Docker container:
docker run -p 8080:8080 spring-rest-service
Or if you want to run in detached mode:
docker run -d -p 8080:8080 spring-rest-service
Once the container is running, the application will be accessible at:
http://localhost:8080/greeting
Project Structure
spring-rest-service/
├── src/
│ ├── main/
│ │ ├── java/com/abidmuin/spring_rest_service/
│ │ │ ├── Greeting.java
│ │ │ ├── GreetingController.java
│ │ └── resources/
│ │ └── application.properties
│ └── test/
│ └── java/
├── Dockerfile
├── pom.xml
└── README.md
You can run tests using Maven:
mvn test
This project is licensed under the MIT License - see the LICENSE file for details.