spring boot 使用demo
来源:互联网 发布:百度云 知乎 编辑:程序博客网 时间:2024/06/05 08:50
官方指引
一. 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. 新建配置文件和程序入口类
通用配置项 application.yml
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-8spring: http: encoding: force: truelogging: 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@SpringBootApplicationpublic class SpringApplication { @RequestMapping("/") @ResponseBody String home() { return "Hello World!"; } public static void main(String[] args) throws Exception { //启动 SpringApplication.run(SampleController.class, args); }}
然后输入http://localhost:8080
二. 日期转换
/** * 日期转换 * @param binder */@InitBinderprotected void initBinder(WebDataBinder binder) { SimpleDateFormat dateFormat = new SimpleDateFormat(DateUtil.YYYY_MM_DD_HH_MM_SS); binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));}
阅读全文
0 0
- spring boot 使用demo
- Spring Boot Demo
- Simple Spring Boot Demo
- spring-boot - demo
- Spring Boot 入门demo
- Spring Boot + WebSocket Demo
- spring-boot-ehcache-demo
- spring-boot-mybatis-demo
- spring-boot-druid-demo
- spring-boot-demo
- spring boot demo-project
- spring-boot idea demo
- spring-boot入门Demo
- spring boot入门demo
- Spring Boot Demo 系列
- Spring boot入门demo
- spring boot thymeleaf 入门 demo
- Spring Boot CLI DEMO Setup
- UVALive4536 POJ3824 HDU3328 Flipper【模拟+堆栈】
- 初识java多线程 (java多线程基础知识汇总)
- 使用Python进行FME的批处理
- sha1sum文件校验
- 对于抽象类与接口的理解
- spring boot 使用demo
- Java反射
- Linux配置定时,使用 crontab -e 与 直接编辑 /etc/crontab 的区别
- 进程、线程间通信方式
- openlayers3 聚合分析专题图 cluster
- Android中点击图片放大的简单方法
- CodeForces 4 A.Watermelon(水~)
- Go语言学习笔记 --- 入门介绍
- Spring boot 整合mybtais和druid