From ee930d56c4358fb00a9b42146e64ce131abb68a1 Mon Sep 17 00:00:00 2001 From: Timoteo Ponce <248934+timoteoponce@users.noreply.github.com> Date: Mon, 14 May 2018 03:10:20 -0400 Subject: [PATCH] BAEL-1696 Initial setup in a workable state (#4173) * BAEL-1696 Initial setup in a workable state * Fixed method name on tomcatController --- pom.xml | 3 +- spring-boot-tomcat/pom.xml | 57 +++++++++++++++++++ .../SpringBootTomcatApplication.java | 13 +++++ .../springbootsimple/TomcatController.java | 18 ++++++ .../src/main/resources/application.properties | 0 .../SpringBootTomcatApplicationTests.java | 16 ++++++ 6 files changed, 106 insertions(+), 1 deletion(-) 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/pom.xml b/pom.xml index fb098a1eb3..a73d7ed357 100644 --- a/pom.xml +++ b/pom.xml @@ -141,6 +141,7 @@ spring-boot-keycloak spring-boot-bootstrap spring-boot-admin + spring-boot-tomcat spring-boot-security spring-cloud-data-flow spring-cloud @@ -530,4 +531,4 @@ 5.0.2 - \ No newline at end of file + diff --git a/spring-boot-tomcat/pom.xml b/spring-boot-tomcat/pom.xml new file mode 100644 index 0000000000..29c8ce95d6 --- /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 0000000000..c9f90683ec --- /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 0000000000..fcf7ecd6c0 --- /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 sayHello() { + 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 0000000000..e69de29bb2 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 0000000000..4c0d4d577a --- /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() { + } + +}