基于spring-boot的rest微服务框架

周末在家研究spring-boot,参考github上的一些开源项目,整了一个rest微服务框架,取之于民,用之于民,在github上开源了,地址如下:

https://github.com/yjmyzz/spring-boot-rest-framework

主要特性如下:

-----------------

数据访问

dao采用mybatis 3.3.0 + tk.mybatis通用Mapper3.1.3 , 支持事务回滚

数据库初始化脚本

见src/mybatis-generator/ddl.sql

数据实体代码生成

采用mybatis-generator 1.3.2生成,生成脚本见src/mybatis-generator/gen.sh

web容器

内嵌tomcat容器,默认开启gzip压缩

日志及监控

所有controller层的参数利用AOP自动记录日志,

参数校验

参数对象采用注解方式自动校验

返回结果

服务结果以json格式返回,如果服务层发生异常,返回结果中自带errorCode及errorDesc,不论服务端方法执行成功与否,均会返回执行结果及服务端耗时

访问地址

http://localhost:8080/ping 这是测试地址,应用启动后,浏览该地址应该返回:

1 {
2 
3     "data": "running",
4     "errorCode": null,
5     "errorDesc": null,
6     "elapsedMilliseconds": ​0,
7     "success": true
8 
9 }

 

其它github参考项目:

rest-nettyserver

spring-boot-samples 

Mapper

mybatis-spring-boot

spring-boot-example

posted @ 2015-11-22 23:05  菩提树下的杨过  阅读(11382)  评论(1编辑  收藏  举报