<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
</parent> <!--Spring Boot的版本仲裁中心;以后我们导入依赖默认是不需要写版本。(没有在dependencies里面管理的依赖自然需要声明版本号)-->
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
spring-boot-starter-web:
spring-boot-starter:spring-boot场景启动器。帮我们导入了web模块正常运行所依赖的组件。
Spring Boot将所有的功能场景都抽取出来,做成一个个的starters(启动器),只需要在项目里面引入这些starter 相关场景的所有依赖都会导入进来。要用什么功能就导入什么场景的启动器
包结构:
HelloController.java
@RestController//标注是一个Controller类 并且支持json数据格式输出
public class HelloController { //通过 http://localhost:8080/sayHello访问该方法
@RequestMapping("/sayHello")
public String hello(){
return "hello world";
}
}
MainTest.java
@SpringBootApplication//代表springboot的启动类 用来标注主程序类 说明是一个springboot应用
public class MainTest {
public static void main(String[] args) { //将springboot应用驱动起来
SpringApplication.run(MainTest.class);
}
}