watch video
step : create spring boot project
step : add dependency
step : create controller Package
and inside that package create HelloController class
HelloController.java
package com.example.demo.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloController {
@GetMapping("/hello")
public String sayHello() {
return "Hello World";
}
}
step : first run project as maven clean
step : then run project as maven install
step : inside target folder you will see the jar file
step : run the jar file
for running the jar
fo to the file location of the project
then go inside target folder
open command prompt inside target folder
execute below cmd
test app in browser
step : create Dockerfile inside spring boot project
paste below inside Dockerfile
FROM eclipse-temurin:17-jdk-alpine
VOLUME /tmp
ADD target/SpringBootDocker-0.0.1-SNAPSHOT.jar SpringBootDocker-0.0.1-SNAPSHOT.jar
ENTRYPOINT ["java","-jar","/SpringBootDocker-0.0.1-SNAPSHOT.jar"]
step:open cmd prompt inside the project
run below cmd
run docker images
run docker image
test inside browser
Top comments (0)