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