Skip to content

Latest commit

 

History

History
56 lines (37 loc) · 2.61 KB

README.md

File metadata and controls

56 lines (37 loc) · 2.61 KB

Spring Boot REST tutorial example

This code came from this tutorial. I later found that Spring actually maintains a repo full of the code for this tutorial with all the trimmings here.

Run the code

To run this code, you need to have Java and Maven installed. Then run the Maven wrapper in the root directory like so:

./mvnw clean spring-boot:run

Package the code

To package this code as a JAR for use in a container, use mvnw like so:

./mvnw package

This will create a file called target/payroll-0.0.1-SNAPSHOT.jar. You can then run it like so:

java -jar target/payroll-0.0.1-SNAPSHOT.jar

Build and run a Docker image

To build a Docker image, you can either create a Dockerfile by hand or use the build-image feature of the Spring Boot build plugin. Detail instructions for both approaches is provided here, but if you'd like the short-short version, make sure you Docker environment is configured and running, and then...

./mvnw spring-boot:build-image -Dspring-boot.build-image.imageName=springio/gs-spring-boot-docker
docker run -p 8080:8080 -t springio/gs-spring-boot-docker

You can also do it the long way using the Dockerfile and the script I created that explodes the JAR file into different layers for efficiency:

./build-fromdockerfile.sh
docker run -p 8080:8080 -t springio/gs-spring-boot-docker

Reference Documentation

For further reference, please consider the following sections:

Guides

The following guides illustrate how to use some features concretely: