diff options
Diffstat (limited to 'spring-boot/01-quick-start')
| -rw-r--r-- | spring-boot/01-quick-start/.gitignore | 1 | ||||
| -rw-r--r-- | spring-boot/01-quick-start/README | 8 | ||||
| -rw-r--r-- | spring-boot/01-quick-start/pom.xml | 15 | ||||
| -rw-r--r-- | spring-boot/01-quick-start/src/main/java/hello/SampleController.java | 31 |
4 files changed, 55 insertions, 0 deletions
diff --git a/spring-boot/01-quick-start/.gitignore b/spring-boot/01-quick-start/.gitignore new file mode 100644 index 0000000..eb5a316 --- /dev/null +++ b/spring-boot/01-quick-start/.gitignore @@ -0,0 +1 @@ +target diff --git a/spring-boot/01-quick-start/README b/spring-boot/01-quick-start/README new file mode 100644 index 0000000..35b5fc7 --- /dev/null +++ b/spring-boot/01-quick-start/README @@ -0,0 +1,8 @@ + Run: + $ mvn spring-boot:run + + Create jar: + $ mvn package + + Run jar: + $ java -jar created-jar-file-x.x.x.jar
\ No newline at end of file diff --git a/spring-boot/01-quick-start/pom.xml b/spring-boot/01-quick-start/pom.xml new file mode 100644 index 0000000..d39a6e5 --- /dev/null +++ b/spring-boot/01-quick-start/pom.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>com.example.spring.boot</groupId> + <artifactId>base-config</artifactId> + <version>0.0.1-SNAPSHOT</version> + <relativePath>../00-config</relativePath> + </parent> + + <artifactId>quick-start</artifactId> + +</project> diff --git a/spring-boot/01-quick-start/src/main/java/hello/SampleController.java b/spring-boot/01-quick-start/src/main/java/hello/SampleController.java new file mode 100644 index 0000000..b0401aa --- /dev/null +++ b/spring-boot/01-quick-start/src/main/java/hello/SampleController.java @@ -0,0 +1,31 @@ +package hello; + +import org.springframework.boot.*; +import org.springframework.boot.autoconfigure.*; +import org.springframework.stereotype.*; +import org.springframework.web.bind.annotation.*; + +/** + * + * @Controller - Indicates that an annotated class is a "Controller" (e.g. a web controller). This annotation serves as a specialization of @Component. + * @EnableAutoConfiguration - This annotation tells Spring Boot to "guess" how you want to configure Spring, based on the jar dependencies that you have added. + * + * @RequestMapping - Map the url pattern to a method + * @ResponseBody - Annotation that indicates a method return value should be bound to the web response body. + * + */ +@Controller +@EnableAutoConfiguration +public class SampleController { + + @RequestMapping("/") + @ResponseBody + String home() { + return "Hello World!"; + } + + public static void main(String[] args) throws Exception { + SpringApplication.run(SampleController.class, args); + } +} + |
