Spring Boot 2.0系列教程(二) Hello World

在《Spring Boot 2.0系列教程(一) 使用IDEA生成Spring Boot 项目》基础上修改build.gradle中依赖为web即可

compile('org.springframework.boot:spring-boot-starter-web')

新增一个类:

@RestController
public class Example {
    @RequestMapping("/")
    String home() {
        return "Hello World!";
    }
}

启动以后访问8080端口,就会返回Hello World!


你可能感兴趣的:(Spring Boot 2.0系列教程(二) Hello World)