[Spring Boot Reference Guide]読書ノート一Getting Started

3519 ワード

8. Introducing Spring Boot
Goals of spring boot:
  • Provide a radically faster and widely accessible getting started experience for all Spring development.
  • Be opinionated out of the box, but get out of the way quickly as requirements start to diverge from the defaults.
  • Provide a range of non-functional features that are common to large classes of projects (e.g. embedded servers, security, metrics, health checks, externalized configuration).
  • Absolutely no code generation and no requirement for XML configuration.

  •  
    9. System Requirements
    Spring Bootには、Tomcat、Jettyなどサーブレット3.0+のWebコンテナが統合されています.
     
    10. Installing Spring Boot
    Spring BootおよびSpring Boot CLIの各種取付方法
     
    11. Developing your first Spring Boot application
    1.
    The spring-boot-starter-parent is a special starter that provides useful Maven defaults. It also provides a dependency-management section so that you can omit version tags for “blessed” dependencies.
    Spring-boot-starter-parentは、必要な依存を提供し、依存バージョンを省略できます.
    Spring-boot-starter-webは、tomcatなどを持参してwebプログラムを生成するために使用できます.
     
    2.コード:
     1 import org.springframework.boot.*;
    
     2 import org.springframework.boot.autoconfigure.*;
    
     3 import org.springframework.stereotype.*;
    
     4 import org.springframework.web.bind.annotation.*;
    
     5 
    
     6 @RestController // REST   ,               
    
     7 @EnableAutoConfiguration //     
    
     8 public class Example {
    
     9     @RequestMapping("/") //   
    
    10     String home() {
    
    11         return "Hello World!";
    
    12     }
    
    13     public static void main(String[] args) throws Exception {
    
    14         SpringApplication.run(Example.class, args);
    
    15     }
    
    16 }

    次のコマンドで起動します.
    mvn spring-boot:run