美文网首页
Spring Boot Hello World

Spring Boot Hello World

作者: Theon66 | 来源:发表于2018-02-02 20:36 被阅读0次

前言

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类

相关文章

网友评论

      本文标题:Spring Boot Hello World

      本文链接:https://www.haomeiwen.com/subject/hdzezxtx.html