From 6cabd68be52d97a55a7d0e71b757dd50344c0289 Mon Sep 17 00:00:00 2001 From: shreyasm Date: Wed, 17 Oct 2018 19:39:26 +0530 Subject: [PATCH] BAEL-2000 - Shreyas Mahajan - Adding a project for demonstrating Spring Boot Jib Maven Plugin (#5375) * BAEL-2000 - Shreyas Mahajan - Adding a project for demonstrating Spring Boot Jib Maven Plugin * BAEL-2000 - Shreyas Mahajan - Incorporating the changes * BAEL-2000 - Shreyas Mahajan - Renaming the module from spring-boot-jib to jib --- jib/pom.xml | 57 +++++++++++++++++++ .../main/java/com/baeldung/Application.java | 12 ++++ jib/src/main/java/com/baeldung/Greeting.java | 20 +++++++ .../java/com/baeldung/GreetingController.java | 20 +++++++ 4 files changed, 109 insertions(+) create mode 100644 jib/pom.xml create mode 100644 jib/src/main/java/com/baeldung/Application.java create mode 100644 jib/src/main/java/com/baeldung/Greeting.java create mode 100644 jib/src/main/java/com/baeldung/GreetingController.java diff --git a/jib/pom.xml b/jib/pom.xml new file mode 100644 index 0000000000..e71250f157 --- /dev/null +++ b/jib/pom.xml @@ -0,0 +1,57 @@ + + 4.0.0 + jib + 0.1-SNAPSHOT + jib + + + parent-boot-2 + com.baeldung + 0.0.1-SNAPSHOT + ../parent-boot-2 + + + + + org.springframework.boot + spring-boot-starter-web + + + + + 1.8 + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + com.google.cloud.tools + jib-maven-plugin + 0.9.10 + + + registry.hub.docker.com/baeldungjib/jib-spring-boot-app + + + + + + + + + spring-releases + https://repo.spring.io/libs-release + + + + + spring-releases + https://repo.spring.io/libs-release + + + diff --git a/jib/src/main/java/com/baeldung/Application.java b/jib/src/main/java/com/baeldung/Application.java new file mode 100644 index 0000000000..8c087476bf --- /dev/null +++ b/jib/src/main/java/com/baeldung/Application.java @@ -0,0 +1,12 @@ +package com.baeldung; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } +} \ No newline at end of file diff --git a/jib/src/main/java/com/baeldung/Greeting.java b/jib/src/main/java/com/baeldung/Greeting.java new file mode 100644 index 0000000000..62834d9752 --- /dev/null +++ b/jib/src/main/java/com/baeldung/Greeting.java @@ -0,0 +1,20 @@ +package com.baeldung; + +public class Greeting { + + private final long id; + private final String content; + + public Greeting(long id, String content) { + this.id = id; + this.content = content; + } + + public long getId() { + return id; + } + + public String getContent() { + return content; + } +} \ No newline at end of file diff --git a/jib/src/main/java/com/baeldung/GreetingController.java b/jib/src/main/java/com/baeldung/GreetingController.java new file mode 100644 index 0000000000..0b082b0001 --- /dev/null +++ b/jib/src/main/java/com/baeldung/GreetingController.java @@ -0,0 +1,20 @@ +package com.baeldung; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.concurrent.atomic.AtomicLong; + +@RestController +public class GreetingController { + + private static final String template = "Hello Docker, %s!"; + private final AtomicLong counter = new AtomicLong(); + + @GetMapping("/greeting") + public Greeting greeting(@RequestParam(value="name", defaultValue="World") String name) { + return new Greeting(counter.incrementAndGet(), + String.format(template, name)); + } +} \ No newline at end of file