This project is licensed under MIT license. See the LICENSE
file for more informations.
This is a simple Spring Boot app to send hello world message to a user.
The reason for this simple project was so that I could pratice and further implement my knowledge in Docker. Therfore, I was able to better understand how a Java Application is containerized using the SpringBoot framework, by creating an Image defined in Dockerfile.
Furthermore, this project also contributed to my development by addresing the good practices of implementing Unit Tests, so I understood that the use of MockMvc allowos testing the control layer of a Spring Application without the need to upload a real server, making tests faster and more efficient.
Start the application using any of the commands mentioned below?
Note: The commands need to run inside the root folder of this project i.e inside the java-docker-helloWorld folder.
-
Using maven
mvn spring-boot:run
-
From jar file Create a jar file using 'mvn clean install' command and then execute.
java -jar target/hello-world-0.0.1-SNAPSHOT.jar.jar
-
Using Docker
- Image construction:
docker build -t image_name .
- Climb Container:
docker run -d --name container_name -p 9090:9090 image_name
- Image construction:
Note: By default spring boot application starts on port number 8080. If port 8080 is occupied in your system then you can change the port number by uncommenting and updating the server.port property inside the application.properties file that is available inside the src > main > resources folder.
Send an HTTP GET request to '/api/hello' endpoint using any of the two methods
-
Browser or REST client
http://localhost:9090/api/hello
-
cURL
curl --request GET 'http://localhost:9090/api/hello'
Run the test cases using any of the commands mentioned below
Note: These commands need to run inside the root folder of this project i.e inside the java-docker-helloWorld folder
-
To run all the test cases
mvn test
-
To run a particular test class
mvn -Dtest=HelloWorldControllerTest test
ormvn -Dtest=HelloWorldApplicationTests test