spring boot-hello world

1.创建maven工程,导入依赖
<parent>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-parent</artifactId>
  <version>1.5.10.RELEASE</version>
</parent>

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

 



2.创建项目启动类
@SpringBootApplication
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}


3.创建controller
@RestController
public class HelloController {

    @GetMapping(value = "/hello")
    public String hello(String name){
        return "hello " + name;
    }
}

 



4.运行第2步中的main方法启动项目,浏览器访问:http://localhost:8080/hello?name=world

 


posted @ 2018-01-31 15:16  谋知  阅读(157)  评论(0编辑  收藏  举报