一. Spring boot maven配置及使用
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
1. 需要使用某一个模块,引入就行,比如web
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
2. 新建配置文件和程序入口类
server:
port: 8080
address: 0.0.0.0
compression:
enabled: true
connection-timeout: 5000
context-path: /
tomcat:
accept-count: 5000
max-connections: 2000
max-threads: 2000
min-spare-threads: 100
uri-encoding: UTF-8
spring:
http:
encoding:
force: true
logging:
file: xxx.log
level:
root: info
程序入口类和demo
package hello;
import org.springframework.boot.*;
import org.springframework.boot.autoconfigure.*;
import org.springframework.stereotype.*;
import org.springframework.web.bind.annotation.*;
@RestController
@SpringBootApplication
public class SpringApplication {
@RequestMapping("/")
@ResponseBody
String home() {
return "Hello World!";
}
public static void main(String[] args) throws Exception {
//启动
SpringApplication.run(SampleController.class, args);
}
}
二. 日期转换
/**
* 日期转换
* @param binder
*/
@InitBinder
protected void initBinder(WebDataBinder binder) {
SimpleDateFormat dateFormat = new SimpleDateFormat(DateUtil.YYYY_MM_DD_HH_MM_SS);
binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
}