From 67cc9d007f2488c162ca7aae858cd23e69a0e2cb Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Mon, 1 Jun 2015 13:24:33 -0700 Subject: [PATCH] Add a spring-boot-developer-tools sample Add a sample application that demonstrates how the `spring-boot-developer-tools` module can be used. Closes gh-3082 --- spring-boot-samples/pom.xml | 1 + .../pom.xml | 52 +++++++++++++++++++ .../src/main/java/demo/Message.java | 23 ++++++++ .../src/main/java/demo/MyController.java | 34 ++++++++++++ .../demo/SampleDeveloperToolsApplication.java | 30 +++++++++++ .../src/main/resources/application.properties | 1 + .../main/resources/static/css/application.css | 9 ++++ .../src/main/resources/templates/hello.html | 22 ++++++++ .../src/main/resources/templates/layout.html | 12 +++++ 9 files changed, 184 insertions(+) create mode 100644 spring-boot-samples/spring-boot-sample-developer-tools/pom.xml create mode 100644 spring-boot-samples/spring-boot-sample-developer-tools/src/main/java/demo/Message.java create mode 100644 spring-boot-samples/spring-boot-sample-developer-tools/src/main/java/demo/MyController.java create mode 100644 spring-boot-samples/spring-boot-sample-developer-tools/src/main/java/demo/SampleDeveloperToolsApplication.java create mode 100644 spring-boot-samples/spring-boot-sample-developer-tools/src/main/resources/application.properties create mode 100644 spring-boot-samples/spring-boot-sample-developer-tools/src/main/resources/static/css/application.css create mode 100644 spring-boot-samples/spring-boot-sample-developer-tools/src/main/resources/templates/hello.html create mode 100644 spring-boot-samples/spring-boot-sample-developer-tools/src/main/resources/templates/layout.html diff --git a/spring-boot-samples/pom.xml b/spring-boot-samples/pom.xml index 474d828daaa..7fbb6b84c71 100644 --- a/spring-boot-samples/pom.xml +++ b/spring-boot-samples/pom.xml @@ -38,6 +38,7 @@ spring-boot-sample-data-redis spring-boot-sample-data-rest spring-boot-sample-data-solr + spring-boot-sample-developer-tools spring-boot-sample-flyway spring-boot-sample-hateoas spring-boot-sample-hornetq diff --git a/spring-boot-samples/spring-boot-sample-developer-tools/pom.xml b/spring-boot-samples/spring-boot-sample-developer-tools/pom.xml new file mode 100644 index 00000000000..dc074080eb6 --- /dev/null +++ b/spring-boot-samples/spring-boot-sample-developer-tools/pom.xml @@ -0,0 +1,52 @@ + + + 4.0.0 + + + org.springframework.boot + spring-boot-samples + 1.3.0.BUILD-SNAPSHOT + + spring-boot-sample-developer-tools + Spring Boot Developer Tools Sample + Spring Boot Developer Tools Sample + http://projects.spring.io/spring-boot/ + + Pivotal Software, Inc. + http://www.spring.io + + + ${basedir}/../.. + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + org.springframework.boot + spring-boot-developer-tools + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + org.springframework.boot + spring-boot-maven-plugin + + false + + + + + diff --git a/spring-boot-samples/spring-boot-sample-developer-tools/src/main/java/demo/Message.java b/spring-boot-samples/spring-boot-sample-developer-tools/src/main/java/demo/Message.java new file mode 100644 index 00000000000..023781f9a62 --- /dev/null +++ b/spring-boot-samples/spring-boot-sample-developer-tools/src/main/java/demo/Message.java @@ -0,0 +1,23 @@ +/* + * Copyright 2012-2015 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package demo; + +public class Message { + + public static String MESSAGE = "Message"; + +} diff --git a/spring-boot-samples/spring-boot-sample-developer-tools/src/main/java/demo/MyController.java b/spring-boot-samples/spring-boot-sample-developer-tools/src/main/java/demo/MyController.java new file mode 100644 index 00000000000..a9d0f429177 --- /dev/null +++ b/spring-boot-samples/spring-boot-sample-developer-tools/src/main/java/demo/MyController.java @@ -0,0 +1,34 @@ +/* + * Copyright 2012-2015 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package demo; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.servlet.ModelAndView; + +@Controller +public class MyController { + + @RequestMapping("/") + public ModelAndView get() { + ModelMap model = new ModelMap("message", Message.MESSAGE); + return new ModelAndView("hello", model); + + } + +} diff --git a/spring-boot-samples/spring-boot-sample-developer-tools/src/main/java/demo/SampleDeveloperToolsApplication.java b/spring-boot-samples/spring-boot-sample-developer-tools/src/main/java/demo/SampleDeveloperToolsApplication.java new file mode 100644 index 00000000000..f0e462b6a66 --- /dev/null +++ b/spring-boot-samples/spring-boot-sample-developer-tools/src/main/java/demo/SampleDeveloperToolsApplication.java @@ -0,0 +1,30 @@ +/* + * Copyright 2012-2015 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package demo; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration.WebMvcAutoConfigurationAdapter; + +@SpringBootApplication +public class SampleDeveloperToolsApplication extends WebMvcAutoConfigurationAdapter { + + public static void main(String[] args) { + SpringApplication.run(SampleDeveloperToolsApplication.class, args); + } + +} diff --git a/spring-boot-samples/spring-boot-sample-developer-tools/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-developer-tools/src/main/resources/application.properties new file mode 100644 index 00000000000..fcd8b00e721 --- /dev/null +++ b/spring-boot-samples/spring-boot-sample-developer-tools/src/main/resources/application.properties @@ -0,0 +1 @@ +spring.developertools.remote.secret=secret diff --git a/spring-boot-samples/spring-boot-sample-developer-tools/src/main/resources/static/css/application.css b/spring-boot-samples/spring-boot-sample-developer-tools/src/main/resources/static/css/application.css new file mode 100644 index 00000000000..6b066803d01 --- /dev/null +++ b/spring-boot-samples/spring-boot-sample-developer-tools/src/main/resources/static/css/application.css @@ -0,0 +1,9 @@ +h1 { + color: blue; +} + +.content { + font-family: sans-serif; + border-top: 3px solid red; + padding-top: 30px; +} diff --git a/spring-boot-samples/spring-boot-sample-developer-tools/src/main/resources/templates/hello.html b/spring-boot-samples/spring-boot-sample-developer-tools/src/main/resources/templates/hello.html new file mode 100644 index 00000000000..ddfe95fa008 --- /dev/null +++ b/spring-boot-samples/spring-boot-sample-developer-tools/src/main/resources/templates/hello.html @@ -0,0 +1,22 @@ + + + +Hello + + +

Header

+
Lorem ipsum dolor sit amet, + consectetur adipiscing elit. Cras ut fringilla augue, quis dictum + turpis. Sed tincidunt mi vel euismod viverra. Nulla facilisi. + Suspendisse mauris dolor, egestas ac leo at, porttitor ullamcorper + leo. Suspendisse consequat, justo ut rutrum interdum, nibh massa + semper dui, id sagittis tellus lectus at nibh. Etiam at scelerisque + nisi. Quisque vel eros tempor, fermentum sapien sed, gravida neque. + Fusce interdum sed dolor a semper. Morbi porta mauris a velit laoreet + viverra. Praesent et tellus vehicula, sagittis mi quis, faucibus urna. + Ut diam tortor, vehicula eget aliquam eget, elementum a odio. Fusce at + nisl sapien. Suspendisse potenti.
+ + diff --git a/spring-boot-samples/spring-boot-sample-developer-tools/src/main/resources/templates/layout.html b/spring-boot-samples/spring-boot-sample-developer-tools/src/main/resources/templates/layout.html new file mode 100644 index 00000000000..c4e7d6d527a --- /dev/null +++ b/spring-boot-samples/spring-boot-sample-developer-tools/src/main/resources/templates/layout.html @@ -0,0 +1,12 @@ + + + +Layout + + + +

Header

+
Content
+ +