1. 打开idea
2. 依次点击File->new->Project
3. 选择Maven点击next,第一次创建的时侯在Project SDK处需要选择jdk
4. 输入项目名称及项目存放路径,坐标会出现在pom.xml中为Maven做准备
5. 在pom.xml中导入SpringBoot相关依赖
org.springframework.boot
spring-boot-starter-parent
1.5.9.RELEASE
org.springframework.boot
spring-boot-starter-web
6. 编写一个主程序;启动Spring Boot应用
@SpringBootApplication
public class HelloWorldMainApplication {
public static void main(String[] args) {
// Spring应用启动起来
SpringApplication.run(HelloWorldMainApplication.class,args);
}
}
7. 编写相关的Controller、Service
@Controller
public class HelloController {
@ResponseBody
@RequestMapping("/hello")
public String hello(){
return "Hello World!";
}
}
8. 浏览器输入localhost:8080/hello就可以执行起来了