1,什么是SpringBootSpring Boot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应用的初始搭建以及开发过程。简化搭建Spring项目的流程提供统一的父类工程,管理常见的第三方组件
2,快速搭建一个SpringBoot项目
3,配置统一的SpringBoot父工程版本
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
4,引入关键的web依赖,用于开发web项目
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
5,引入关键的dev依赖,用于实现热部署
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
注意:idea还需要额外做两个设置 打开自动编译:
File -> Settings -> Build,Execution,Deployment->Compiler下,
打开Build project automatically选项 打开运行时编译: 按快捷键 Shift+Ctrl+Alt+/ ,
选择 Registr 打开 compiler.automake.allow.when.app.running选项
6,配置application.properpties
server.port=8081
server.context-path=/springboot
#设置对输入参数的格式化,这样后台的接口就可以接收Date类型
spring.mvc.date-format=yyyy-MM-dd
#设置对输出参数的格式化
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
#北京时间相对伦敦有8个小时时差所以使用GMT+8,这样才能正常显示日期
spring.jackson.time-zone=GMT+8
#fastdfs
images.serverpath = http://images.qf.com
通过@Value获取属性文件的值
@Value("${images.serverpath}")
private String imageServer
接收日期,并返回
@RequestMapping("showDate")
@ResponseBody
public Date showDate(Date date){
//接收日期
System.out.println(date);
//返回日期
return date;
}