From 0058551424e2160641d7b522149a86b03a6ed014 Mon Sep 17 00:00:00 2001 From: Timoteo Ponce Date: Fri, 4 May 2018 15:20:15 -0400 Subject: [PATCH 1/2] BAEL-1696 Initial setup in a workable state --- spring-boot-tomcat/pom.xml | 57 +++++++++++++++++++ .../SpringBootTomcatApplication.java | 13 +++++ .../springbootsimple/TomcatController.java | 18 ++++++ .../src/main/resources/application.properties | 0 .../SpringBootTomcatApplicationTests.java | 16 ++++++ 5 files changed, 104 insertions(+) create mode 100644 spring-boot-tomcat/pom.xml create mode 100644 spring-boot-tomcat/src/main/java/com/baeldung/springbootsimple/SpringBootTomcatApplication.java create mode 100644 spring-boot-tomcat/src/main/java/com/baeldung/springbootsimple/TomcatController.java create mode 100644 spring-boot-tomcat/src/main/resources/application.properties create mode 100644 spring-boot-tomcat/src/test/java/com/baeldung/springbootsimple/SpringBootTomcatApplicationTests.java diff --git a/spring-boot-tomcat/pom.xml b/spring-boot-tomcat/pom.xml new file mode 100644 index 000000000000..29c8ce95d6d9 --- /dev/null +++ b/spring-boot-tomcat/pom.xml @@ -0,0 +1,57 @@ + + + 4.0.0 + + com.baeldung + spring-boot-tomcat + 0.0.1-SNAPSHOT + war + + spring-boot-tomcat + Demo project for Spring Boot and Tomcat setup + + + org.springframework.boot + spring-boot-starter-parent + 2.0.1.RELEASE + + + + + UTF-8 + UTF-8 + 1.8 + + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-tomcat + provided + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + ${artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + diff --git a/spring-boot-tomcat/src/main/java/com/baeldung/springbootsimple/SpringBootTomcatApplication.java b/spring-boot-tomcat/src/main/java/com/baeldung/springbootsimple/SpringBootTomcatApplication.java new file mode 100644 index 000000000000..c9f90683ec35 --- /dev/null +++ b/spring-boot-tomcat/src/main/java/com/baeldung/springbootsimple/SpringBootTomcatApplication.java @@ -0,0 +1,13 @@ +package com.baeldung.springbootsimple; + +import org.springframework.boot.*; +import org.springframework.boot.autoconfigure.*; +import org.springframework.boot.web.servlet.support.*; + +@SpringBootApplication +public class SpringBootTomcatApplication extends SpringBootServletInitializer { + + public static void main(String[] args) { + SpringApplication.run(SpringBootTomcatApplication.class, args); + } +} diff --git a/spring-boot-tomcat/src/main/java/com/baeldung/springbootsimple/TomcatController.java b/spring-boot-tomcat/src/main/java/com/baeldung/springbootsimple/TomcatController.java new file mode 100644 index 000000000000..809d814afac2 --- /dev/null +++ b/spring-boot-tomcat/src/main/java/com/baeldung/springbootsimple/TomcatController.java @@ -0,0 +1,18 @@ +package com.baeldung.springbootsimple; + +import org.springframework.web.bind.annotation.*; + +import java.util.*; +import java.util.stream.*; + +@RestController +public class TomcatController { + + @GetMapping(value = "/hello") + public Collection getInfo() { + return IntStream.range(0, 10) + .mapToObj(i -> "Hello number " + i) + .collect(Collectors.toList()); + } + +} diff --git a/spring-boot-tomcat/src/main/resources/application.properties b/spring-boot-tomcat/src/main/resources/application.properties new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/spring-boot-tomcat/src/test/java/com/baeldung/springbootsimple/SpringBootTomcatApplicationTests.java b/spring-boot-tomcat/src/test/java/com/baeldung/springbootsimple/SpringBootTomcatApplicationTests.java new file mode 100644 index 000000000000..4c0d4d577a38 --- /dev/null +++ b/spring-boot-tomcat/src/test/java/com/baeldung/springbootsimple/SpringBootTomcatApplicationTests.java @@ -0,0 +1,16 @@ +package com.baeldung.springbootsimple; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class SpringBootTomcatApplicationTests { + + @Test + public void contextLoads() { + } + +} From b5914c1a86f8ba7241cf02cec6c518bbbcaff9c5 Mon Sep 17 00:00:00 2001 From: Timoteo Ponce Date: Mon, 7 May 2018 15:19:59 -0400 Subject: [PATCH 2/2] Fixed method name on tomcatController --- pom.xml | 3 ++- .../java/com/baeldung/springbootsimple/TomcatController.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 98e7f76e8648..41844cca222b 100644 --- a/pom.xml +++ b/pom.xml @@ -138,6 +138,7 @@ spring-boot-keycloak spring-boot-bootstrap spring-boot-admin + spring-boot-tomcat spring-boot-security spring-cloud-data-flow spring-cloud @@ -518,4 +519,4 @@ 1.3 - \ No newline at end of file + diff --git a/spring-boot-tomcat/src/main/java/com/baeldung/springbootsimple/TomcatController.java b/spring-boot-tomcat/src/main/java/com/baeldung/springbootsimple/TomcatController.java index 809d814afac2..fcf7ecd6c0e7 100644 --- a/spring-boot-tomcat/src/main/java/com/baeldung/springbootsimple/TomcatController.java +++ b/spring-boot-tomcat/src/main/java/com/baeldung/springbootsimple/TomcatController.java @@ -9,7 +9,7 @@ public class TomcatController { @GetMapping(value = "/hello") - public Collection getInfo() { + public Collection sayHello() { return IntStream.range(0, 10) .mapToObj(i -> "Hello number " + i) .collect(Collectors.toList());