Spring Boot Hello World

2018-02-02  本文已影响0人  Theon66

前言

Spring Boot makes it easy to create stand-alone, production-grade Spring-based Applications that you can run. We take an opinionated view of the Spring platform and third-party libraries, so that you can get started with minimum fuss. Most Spring Boot applications need very little Spring configuration.

Our primary goals are:
● 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 (such as embedded servers, security, metrics, health checks, and externalized configuration).
● Absolutely no code generation and no requirement for XML configuration.

1.生成项目结构

Spring Initializr

2.POM中添加web依赖

     <dependency>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter-web</artifactId>
     </dependency>

3.编写controller

@RestController
@SpringBootApplication
public class DemoApplication {

    @RequestMapping("/")
    String home() {
        return "Hello World";
    }
    
    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
}

直接运行当前controller类

上一篇 下一篇

猜你喜欢

热点阅读