diff --git a/README.md b/README.md index cc17360c..6d0d615c 100644 --- a/README.md +++ b/README.md @@ -1,93 +1,112 @@ -# springboot-learning-example -spring boot 实践学习案例,是 spring boot 初学者及核心技术巩固的最佳实践。 - -# 推荐 -由于工作原因,我发表原创博客也需要编写的时间。期间很多人私我问题,没有及时得到回复,这里说声抱歉。因此,建一个星球 - -「泥瓦匠BYSocket」和朋友们讨论技术相关的话题,你一起来吧? - -[泥瓦匠BYSocket 星球](https://t.zsxq.com/nMzjqbe "泥瓦匠BYSocket") - -[泥瓦匠BYSocket 星球](https://t.zsxq.com/nMzjqbe "泥瓦匠BYSocket") - -[泥瓦匠BYSocket 星球](https://t.zsxq.com/nMzjqbe "泥瓦匠BYSocket") - -这个星球里面讲深入讨论 Java 、Java EE、Spring Boot 等框架技术及工作经验交流,分享一路技术走来的经验、教训。硬实力软实力、择业、职业规划等。 - -## 计划 -Spring Boot 2.0 最大的热点肯定是 Web Flux。我这边也就开始操刀了... - -Web Flux 努力进行中,尽情期待。唯一文章入口:[GitChat文章地址](http://gitbook.cn/gitchat/author/58968d35f2b669527d7a7c57 "gitchat") - -## Spring For All 社区 -[Spring For All 社区](http://www.spring4all.com/ "spring4all")是新组建的关于 Spring 的纯技术交流社区(涵盖 Spring Boot、Spring Cloud 等内容),集诸多开源爱好者和技术大牛贡献内容和交流问题。我们不夸大、不装逼、做最纯粹的技术分享!!! - -看看我们超强的群众基础,欢迎有兴趣的朋友加入QQ群分享与交流:[点击立即加入](http://www.spring4all.com/about "about") - -## 作者与学习乐园 -源码地址:我的[GitHub地址](https://github.com/JeffLi1993 "GitHub")、[OSCGit地址](https://git.oschina.net/jeff1993/springboot-learning-example "OSCGit")
-作者:[泥瓦匠BYSocket](http://www.bysocket.com/ "泥瓦匠BYSocket")
-关注微信公众号【泥瓦匠BYSokcet】,及时得到技术文章推送
-![公众号](http://www.bysocket.com/wp-content/uploads/2017/01/qrcode_for_gh_cd421e7eb7d6_430.jpg) - -## 一、项目结构 -「Spring Boot 那些事」:[传送门](http://www.bysocket.com/?page_id=1639 "Spring Boot 那些事")
- -### 『 WebFlux 篇 』 - -WebFlux 系类文章入口:[GitChat文章地址](http://gitbook.cn/gitchat/author/58968d35f2b669527d7a7c57 "gitchat") - -- springboot-webflux
-Spring Boot WebFlux 实现 Restful 服务 - - -#### a. 『 基础 - 入门篇 』 -- springboot-helloworld
- [《Spring Boot 之 HelloWorld 详解》](http://www.bysocket.com/?p=1124 "Spring Boot 之 HelloWorld详解")
-- springboot-properties
- [《Spring Boot 之配置文件详解》](http://www.bysocket.com/?p=1786 "Spring Boot 之配置文件详解")
- -#### b. 『 基础 - Web 业务开发篇 』 -- springboot-restful
- [《Springboot 实现 Restful 服务,基于 HTTP / JSON 传输》](http://www.bysocket.com/?p=1627 "Springboot 实现 Restful 服务,基于 HTTP / JSON 传输")
- [《Spring Boot 之 RESRful API 权限控制》](http://www.bysocket.com/?p=1080 "Spring Boot 之 RESRful API 权限控制")
-- springboot-freemarker
-[《Spring Boot 集成 FreeMarker 详解案例》](http://www.bysocket.com/?p=1666 "Spring Boot 集成 FreeMarker 详解案例")
-- springboot-validation-over-json -[《Spring Boot HTTP over JSON 的错误码异常处理》](http://www.bysocket.com/?p=1692 "Spring Boot HTTP over JSON 的错误码异常处理")
- - -#### c. 『 基础 – 数据存储篇 』 -- springboot-mybatis
- [《Springboot 整合 Mybatis 的完整 Web 案例》](http://www.bysocket.com/?p=1610 "Springboot 整合 Mybatis 的完整 Web 案例")
-- springboot-mybatis-annotation
- [《Spring Boot 整合 Mybatis Annotation 注解的完整 Web 案例》](http://www.bysocket.com/?p=1811 "Spring Boot 整合 Mybatis Annotation 注解的完整 Web 案例")
-- springboot-mybatis-mutil-datasource
- [《Spring Boot 整合 Mybatis 实现 Druid 多数据源详解》](http://www.bysocket.com/?p=1712 "Spring Boot 整合 Mybatis 实现 Druid 多数据源详解")
- - -#### d. 『 基础 – 数据缓存篇 』 -- springboot-mybatis-redis
- [《Spring Boot 整合 Redis 实现缓存操作》](http://www.bysocket.com/?p=1756 "Spring Boot 整合 Mybatis 实现 Druid 多数据源详解")
-- springboot-mybatis-redis-annotation
- [《Spring Boot 注解实现整合 Redis 作为缓存》](http://www.bysocket.com/?p=1756 "Spring Boot 整合 Mybatis 实现 Druid 多数据源详解")
- -#### e. 『 其他篇 』 -- springboot-elasticsearch
- [《Spring Boot 整合 Elasticsearch,实现 function score query 权重分查询》](http://www.bysocket.com/?p=1829 "Spring Boot 整合 Elasticsearch,实现 function score query 权重分查询")
-- springboot-dubbo-server
-- springboot-dubbo-client
-Dubbo 服务提供者工程和 Dubbo 服务消费者工程
- [《Springboot 整合 Dubbo/ZooKeeper 详解 SOA 案例》](http://www.bysocket.com/?p=1681 "Springboot 整合 Dubbo/ZooKeeper 详解 SOA 案例")
- [《Spring Boot 中如何使用 Dubbo Activate 扩展点》](http://www.bysocket.com/?p=1782 "Spring Boot 中如何使用 Dubbo Activate 扩展点")
- - -#### 『 Spring Data ES 篇 』 -- spring-data-elasticsearch-crud
- [《Spring Data Elasticsearch - 基本案例》](http://spring4all.com/article/70 "Spring Data Elasticsearch - 基本案例")
-- spring-data-elasticsearch-query
-spring-data-elasticsearch - 实战案例详解 - -最后,
- - [《Spring Boot教程与Spring Cloud教程》](https://git.oschina.net/didispace/SpringBoot-Learning "Spring Boot教程与Spring Cloud教程")
+### 谢谢赞助的ta们 + + + + + + + +
+ + + + + + + +
+ +**Spring Boot 2.x 系列教程**,spring boot 实践学习案例,是初学者及核心技术巩固的最佳实践。 + +### 一、支持泥瓦匠 +1. 拿起微信,关注博客左侧公众号:「泥瓦匠BYSocket 」 +2. 给教程的开源代码仓库点个 **Star** 吧 + - [GitHub(springboot-learning-example)](https://github.com/JeffLi1993/springboot-learning-example "GitHub(springboot-learning-example)") + - [Gitee(springboot-learning-example)](https://gitee.com/jeff1993/springboot-learning-example "Gitee(springboot-learning-example)") +3. 帮忙分享该系列文章链接给更多的朋友 + +> 如果您对文字类教程不感冒或者想要通过综合案例学习Spring,那么给您推荐这个我觉得目前内容与价格最良心的视频课程:[“玩转Spring全家桶”](https://time.geekbang.org/course/intro/156?code=zqaEuXYpWbKaPeBaJc8GVoYCUHvoGhTlQQ7QZYoWWdI%3D&utm_term=zeusDUJ0V&utm_source=website&utm_medium=bysocket "“玩转Spring全家桶”") + +### 二、系列文章目录 + +#### 『 基础 - 入门篇 』 +- [Spring Boot 2.0 配置图文教程](https://www.bysocket.com/archives/2135) +- [Spring Boot 2.0 的快速入门(图文教程)](https://www.bysocket.com/archives/2119) +- [Spring Boot 之 HelloWorld 详解](http://www.bysocket.com/?p=1124) +- [Spring Boot 之配置文件详解](http://www.bysocket.com/?p=1786) + +#### 『 基础 - Web 业务开发篇 』 +- [Spring Boot Web 开发注解篇](http://www.bysocket.com/?p=1929) +- [Spring Boot 表单验证篇](http://www.bysocket.com/?p=1942) +- [Spring Boot 2.x 小新功能 – Spring Data Web configuration](http://www.bysocket.com/?p=1950) +- [Spring Boot 实现 Restful 服务,基于 HTTP / JSON 传输](http://www.bysocket.com/?p=1627) +- [Spring Boot 之 RESRful API 权限控制](http://www.bysocket.com/?p=1080) +- [Spring Boot 集成 FreeMarker](http://www.bysocket.com/?p=1666) +- [Spring Boot HTTP over JSON 的错误码异常处理](http://www.bysocket.com/?p=1692) +- Spring Boot 使用 Swagger2 构建 RESRful API 文档 +- Spring Boot 集成 JSP +- Spring Boot 集成 Thymeleaf +- Spring Boot 单元测试的使用 +- Spring Boot 热更新部署 + +#### 『 基础 – 数据存储篇 』 +- [Spring Boot 整合 Mybatis 的完整 Web 案例](http://www.bysocket.com/?p=1610) +- [Spring Boot 整合 Mybatis Annotation 注解案例](http://www.bysocket.com/?p=1811) +- [Spring Boot 整合 Mybatis 实现 Druid 多数据源配置](http://www.bysocket.com/?p=1712) +- Spring Boot 整合使用 JdbcTemplate +- Spring Boot 整合 Spring-data-jpa +- Spring Boot 声明式事务管理 + +#### 『 基础 – 数据缓存篇 』 +- [Spring Boot 整合 Redis 实现缓存操作](http://www.bysocket.com/?p=1756) +- Spring Boot 整合 Redis Annotation 实现缓存操作 +- Spring Boot 整合 MongoDB 实现缓存操作 +- Spring Boot 整合 EhCache 实现缓存操作 + +#### 『 基础 – 日志管理篇 』 +- Spring Boot 默认日志 logback 配置解析 +- Spring Boot 使用 log4j 记录日志 +- Spring Boot 对 log4j 进行多环境不同日志级别的控制 +- Spring Boot 使用 log4j 记录日志到 MongoDB +- Spring Boot 1.5.x 动态修改日志级别 + +#### 『 基础 – 应用篇 』 +- Spring Boot Actuator 监控 +- Spring Boot Web 应用部署 + +#### 『 提升 – 安全控制及权限篇 』 +- Spring Boot 整合 Spring Security +- Spring Boot 整合 Shiro +- Spring Boot 整合 Spring Session + +#### 『 提升 – 中间件篇 』 +- [Spring Boot 2.x :通过 spring-boot-starter-hbase 集成 HBase](https://www.bysocket.com/archives/2162) +- Spring Boot 整合 RabbitMQ +- Spring Boot 整合 Quartz + +#### 『 提升 – 源码篇 』 +- Spring Boot 启动原理解析 + +#### 『 Elasticsearch 篇 』 +- [Spring Boot 整合 Elasticsearch](http://www.bysocket.com/?p=1829) +- [深入浅出 spring-data-elasticsearch 之 ElasticSearch 架构初探(一)](http://www.bysocket.com/?p=1889) +- [深入浅出 spring-data-elasticsearch 系列 – 概述及入门(二)](http://www.bysocket.com/?p=1894) +- [深入浅出 spring-data-elasticsearch – 基本案例详解(三)](http://www.bysocket.com/?p=1899) +- [深入浅出 spring-data-elasticsearch – 实战案例详解(四)](http://www.bysocket.com/?p=1902) + +#### 『 Dubbo 篇 』 +- [Spring Boot 整合 Dubbo/ZooKeeper 详解 SOA 案例](http://www.bysocket.com/?p=1681) +- [Spring Boot 中如何使用 Dubbo Activate 扩展点](http://www.bysocket.com/?p=1782) +- [Spring Boot Dubbo applications.properties 配置清单](http://www.bysocket.com/?p=1805) + +### 三、最后推荐 + +- [我的博客](http://www.bysocket.com "我的博客"):分享学习可落地的技术博文 +- [我的GitHub](https://github.com/JeffLi1993 "我的GitHub"):Follow 下呗 +- [我的Gitee](https://gitee.com/jeff1993 "我的Gitee"):Follow 下呗 +- [Spring问答社区](http://www.spring4all.com/ "Spring问答社区"):如果您有什么问题,可以去这里发帖 + +### 四、我的公号 +关注微信公众号,领取 Java 精选干货学习资料 + + diff --git a/chapter-1-spring-boot-quickstart/pom.xml b/chapter-1-spring-boot-quickstart/pom.xml index b709729a..7e47fc49 100644 --- a/chapter-1-spring-boot-quickstart/pom.xml +++ b/chapter-1-spring-boot-quickstart/pom.xml @@ -13,7 +13,7 @@ org.springframework.boot spring-boot-starter-parent - 1.5.1.RELEASE + 2.1.3.RELEASE diff --git a/chapter-2-spring-boot-config/pom.xml b/chapter-2-spring-boot-config/pom.xml index cc088fc9..e24ffdee 100644 --- a/chapter-2-spring-boot-config/pom.xml +++ b/chapter-2-spring-boot-config/pom.xml @@ -13,7 +13,7 @@ org.springframework.boot spring-boot-starter-parent - 2.0.0.BUILD-SNAPSHOT + 2.1.3.RELEASE @@ -52,7 +52,7 @@ org.springframework.boot spring-boot-maven-plugin - 1.5.1.RELEASE + 2.1.3.RELEASE diff --git a/chapter-3-spring-boot-web/pom.xml b/chapter-3-spring-boot-web/pom.xml index b40d56f2..780e9ea5 100644 --- a/chapter-3-spring-boot-web/pom.xml +++ b/chapter-3-spring-boot-web/pom.xml @@ -13,7 +13,7 @@ org.springframework.boot spring-boot-starter-parent - 2.0.0.BUILD-SNAPSHOT + 2.1.3.RELEASE diff --git a/chapter-4-spring-boot-validating-form-input/pom.xml b/chapter-4-spring-boot-validating-form-input/pom.xml index 35ab84c2..2c634719 100644 --- a/chapter-4-spring-boot-validating-form-input/pom.xml +++ b/chapter-4-spring-boot-validating-form-input/pom.xml @@ -71,7 +71,7 @@ org.springframework.boot spring-boot-maven-plugin - 1.5.1.RELEASE + 2.1.3.RELEASE diff --git a/chapter-4-spring-boot-web-thymeleaf/pom.xml b/chapter-4-spring-boot-web-thymeleaf/pom.xml index 2d3bfffa..ede4d5fa 100644 --- a/chapter-4-spring-boot-web-thymeleaf/pom.xml +++ b/chapter-4-spring-boot-web-thymeleaf/pom.xml @@ -13,7 +13,7 @@ org.springframework.boot spring-boot-starter-parent - 2.0.0.BUILD-SNAPSHOT + 2.1.3.RELEASE diff --git a/chapter-5-spring-boot-data-jpa/pom.xml b/chapter-5-spring-boot-data-jpa/pom.xml index fd1d2eb9..c8789cc3 100644 --- a/chapter-5-spring-boot-data-jpa/pom.xml +++ b/chapter-5-spring-boot-data-jpa/pom.xml @@ -13,7 +13,7 @@ org.springframework.boot spring-boot-starter-parent - 2.0.0.BUILD-SNAPSHOT + 2.1.3.RELEASE diff --git a/chapter-5-spring-boot-paging-sorting/pom.xml b/chapter-5-spring-boot-paging-sorting/pom.xml index 77efa6aa..71797fb8 100644 --- a/chapter-5-spring-boot-paging-sorting/pom.xml +++ b/chapter-5-spring-boot-paging-sorting/pom.xml @@ -60,7 +60,7 @@ org.springframework.boot spring-boot-maven-plugin - 1.5.1.RELEASE + 2.1.3.RELEASE diff --git a/chapter-6-spring-boot-cache-redis/pom.xml b/chapter-6-spring-boot-cache-redis/pom.xml index 690eb60d..01348888 100644 --- a/chapter-6-spring-boot-cache-redis/pom.xml +++ b/chapter-6-spring-boot-cache-redis/pom.xml @@ -13,7 +13,7 @@ org.springframework.boot spring-boot-starter-parent - 2.0.0.BUILD-SNAPSHOT + 2.1.3.RELEASE diff --git a/pom.xml b/pom.xml index 01b6e17f..253246c7 100644 --- a/pom.xml +++ b/pom.xml @@ -73,13 +73,14 @@ chapter-5-spring-boot-data-jpa - chapter-6-spring-boot-cache-redis + chapter-4-spring-boot-validating-form-input chapter-5-spring-boot-paging-sorting + springboot-hbase diff --git a/springboot-configuration/pom.xml b/springboot-configuration/pom.xml index 8dd6a77d..5a3df0dc 100755 --- a/springboot-configuration/pom.xml +++ b/springboot-configuration/pom.xml @@ -12,7 +12,7 @@ org.springframework.boot spring-boot-starter-parent - 1.5.1.RELEASE + 2.1.3.RELEASE diff --git a/springboot-dubbo-client/pom.xml b/springboot-dubbo-client/pom.xml index 0253e58a..6b69be3e 100755 --- a/springboot-dubbo-client/pom.xml +++ b/springboot-dubbo-client/pom.xml @@ -12,7 +12,7 @@ org.springframework.boot spring-boot-starter-parent - 1.5.1.RELEASE + 2.1.3.RELEASE diff --git a/springboot-dubbo-server/pom.xml b/springboot-dubbo-server/pom.xml index e156bc50..07316582 100755 --- a/springboot-dubbo-server/pom.xml +++ b/springboot-dubbo-server/pom.xml @@ -12,7 +12,7 @@ org.springframework.boot spring-boot-starter-parent - 1.5.1.RELEASE + 2.1.3.RELEASE diff --git a/springboot-freemarker/pom.xml b/springboot-freemarker/pom.xml index a756b199..6be3f200 100755 --- a/springboot-freemarker/pom.xml +++ b/springboot-freemarker/pom.xml @@ -12,7 +12,7 @@ org.springframework.boot spring-boot-starter-parent - 1.5.1.RELEASE + 2.1.3.RELEASE diff --git a/springboot-freemarker/src/main/resources/application.properties b/springboot-freemarker/src/main/resources/application.properties index 981c14e5..48f9adbe 100644 --- a/springboot-freemarker/src/main/resources/application.properties +++ b/springboot-freemarker/src/main/resources/application.properties @@ -1,7 +1,7 @@ ## 数据源配置 -spring.datasource.url=jdbc:mysql://139.224.14.39:3306/springbootdb?useUnicode=true&characterEncoding=utf8 +spring.datasource.url=jdbc:mysql://127.0.0.1:3306/springbootdb?useUnicode=true&characterEncoding=utf8 spring.datasource.username=root -spring.datasource.password=Hello123!@ +spring.datasource.password=XX spring.datasource.driver-class-name=com.mysql.jdbc.Driver ## Mybatis 配置 @@ -18,4 +18,4 @@ spring.freemarker.content-type=text/html spring.freemarker.expose-request-attributes=true spring.freemarker.expose-session-attributes=true spring.freemarker.request-context-attribute=request -spring.freemarker.suffix=.ftl \ No newline at end of file +spring.freemarker.suffix=.ftl diff --git a/springboot-hbase/pom.xml b/springboot-hbase/pom.xml new file mode 100755 index 00000000..00aca67b --- /dev/null +++ b/springboot-hbase/pom.xml @@ -0,0 +1,52 @@ + + + 4.0.0 + + springboot + springboot-hbase + 0.0.1-SNAPSHOT + springboot-hbase :: 集成 HBase + + + + org.springframework.boot + spring-boot-starter-parent + 1.5.6.RELEASE + + + + 1.0.0.RELEASE + 5.1.39 + + + + + + + org.springframework.boot + spring-boot-starter-web + + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + com.spring4all + spring-boot-starter-hbase + ${hbase-spring-boot} + + + + + junit + junit + 4.12 + + + diff --git a/springboot-hbase/src/main/java/org/spring/springboot/Application.java b/springboot-hbase/src/main/java/org/spring/springboot/Application.java new file mode 100644 index 00000000..5070937d --- /dev/null +++ b/springboot-hbase/src/main/java/org/spring/springboot/Application.java @@ -0,0 +1,20 @@ +package org.spring.springboot; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * Spring Boot 应用启动类 + * + * Created by bysocket on 16/4/26. + */ +// Spring Boot 应用的标识 +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + // 程序启动入口 + // 启动嵌入式的 Tomcat 并初始化 Spring 环境及其各 Spring 组件 + SpringApplication.run(Application.class,args); + } +} diff --git a/springboot-hbase/src/main/java/org/spring/springboot/controller/CityRestController.java b/springboot-hbase/src/main/java/org/spring/springboot/controller/CityRestController.java new file mode 100644 index 00000000..06470b7d --- /dev/null +++ b/springboot-hbase/src/main/java/org/spring/springboot/controller/CityRestController.java @@ -0,0 +1,31 @@ +package org.spring.springboot.controller; + +import org.spring.springboot.domain.City; +import org.spring.springboot.service.CityService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +/** + * Created by bysocket on 07/02/2017. + */ +@RestController +public class CityRestController { + + @Autowired + private CityService cityService; + + @RequestMapping(value = "/api/city/save", method = RequestMethod.GET) + public City save() { + cityService.saveOrUpdate(); + City city = new City(); + city.setAge(1); + return city; + } + + @RequestMapping(value = "/api/city/get", method = RequestMethod.GET) + public City getCity() { + return cityService.query("135xxxxxx"); + } +} diff --git a/springboot-hbase/src/main/java/org/spring/springboot/dao/CityRowMapper.java b/springboot-hbase/src/main/java/org/spring/springboot/dao/CityRowMapper.java new file mode 100644 index 00000000..9db7db92 --- /dev/null +++ b/springboot-hbase/src/main/java/org/spring/springboot/dao/CityRowMapper.java @@ -0,0 +1,24 @@ +package org.spring.springboot.dao; + +import com.spring4all.spring.boot.starter.hbase.api.RowMapper; +import org.apache.hadoop.hbase.client.Result; +import org.apache.hadoop.hbase.util.Bytes; +import org.spring.springboot.domain.City; + +public class CityRowMapper implements RowMapper { + + private static byte[] COLUMN_FAMILY = "f".getBytes(); + private static byte[] NAME = "name".getBytes(); + private static byte[] AGE = "age".getBytes(); + + @Override + public City mapRow(Result result, int rowNum) throws Exception { + String name = Bytes.toString(result.getValue(COLUMN_FAMILY, NAME)); + int age = Bytes.toInt(result.getValue(COLUMN_FAMILY, AGE)); + + City dto = new City(); + dto.setCityName(name); + dto.setAge(age); + return dto; + } +} diff --git a/springboot-hbase/src/main/java/org/spring/springboot/domain/City.java b/springboot-hbase/src/main/java/org/spring/springboot/domain/City.java new file mode 100644 index 00000000..afe589e2 --- /dev/null +++ b/springboot-hbase/src/main/java/org/spring/springboot/domain/City.java @@ -0,0 +1,48 @@ +package org.spring.springboot.domain; + +/** + * 城市实体类 + * + * Created by bysocket on 07/02/2017. + */ +public class City { + + /** + * 城市编号 + */ + private Long id; + + /** + * 省份年龄 + */ + private Integer age; + + /** + * 城市名称 + */ + private String cityName; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Integer getAge() { + return age; + } + + public void setAge(Integer age) { + this.age = age; + } + + public String getCityName() { + return cityName; + } + + public void setCityName(String cityName) { + this.cityName = cityName; + } +} diff --git a/springboot-hbase/src/main/java/org/spring/springboot/service/CityService.java b/springboot-hbase/src/main/java/org/spring/springboot/service/CityService.java new file mode 100644 index 00000000..cb183e56 --- /dev/null +++ b/springboot-hbase/src/main/java/org/spring/springboot/service/CityService.java @@ -0,0 +1,19 @@ +package org.spring.springboot.service; + +import org.spring.springboot.domain.City; + +import java.util.List; + +/** + * 城市业务逻辑接口类 + *

+ * Created by bysocket on 07/02/2017. + */ +public interface CityService { + + List query(String startRow, String stopRow); + + public City query(String row); + + void saveOrUpdate(); +} diff --git a/springboot-hbase/src/main/java/org/spring/springboot/service/impl/CityServiceImpl.java b/springboot-hbase/src/main/java/org/spring/springboot/service/impl/CityServiceImpl.java new file mode 100644 index 00000000..72b7bf75 --- /dev/null +++ b/springboot-hbase/src/main/java/org/spring/springboot/service/impl/CityServiceImpl.java @@ -0,0 +1,47 @@ +package org.spring.springboot.service.impl; + +import com.spring4all.spring.boot.starter.hbase.api.HbaseTemplate; +import org.apache.hadoop.hbase.client.Mutation; +import org.apache.hadoop.hbase.client.Put; +import org.apache.hadoop.hbase.client.Scan; +import org.apache.hadoop.hbase.util.Bytes; +import org.spring.springboot.dao.CityRowMapper; +import org.spring.springboot.domain.City; +import org.spring.springboot.service.CityService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +/** + * 城市业务逻辑实现类 + *

+ * Created by bysocket on 07/02/2017. + */ +@Service +public class CityServiceImpl implements CityService { + + @Autowired private HbaseTemplate hbaseTemplate; + + public List query(String startRow, String stopRow) { + Scan scan = new Scan(Bytes.toBytes(startRow), Bytes.toBytes(stopRow)); + scan.setCaching(5000); + List dtos = this.hbaseTemplate.find("people_table", scan, new CityRowMapper()); + return dtos; + } + + public City query(String row) { + City dto = this.hbaseTemplate.get("people_table", row, new CityRowMapper()); + return dto; + } + + public void saveOrUpdate() { + List saveOrUpdates = new ArrayList(); + Put put = new Put(Bytes.toBytes("135xxxxxx")); + put.addColumn(Bytes.toBytes("people"), Bytes.toBytes("name"), Bytes.toBytes("test")); + saveOrUpdates.add(put); + + this.hbaseTemplate.saveOrUpdates("people_table", saveOrUpdates); + } +} diff --git a/springboot-hbase/src/main/resources/application.properties b/springboot-hbase/src/main/resources/application.properties new file mode 100644 index 00000000..03ccb627 --- /dev/null +++ b/springboot-hbase/src/main/resources/application.properties @@ -0,0 +1,4 @@ +## HBase 配置 +spring.data.hbase.quorum=xxx +spring.data.hbase.rootDir=xxx +spring.data.hbase.nodeParent=xxx diff --git a/springboot-helloworld/pom.xml b/springboot-helloworld/pom.xml index ca3bda25..90ae6e64 100755 --- a/springboot-helloworld/pom.xml +++ b/springboot-helloworld/pom.xml @@ -12,7 +12,7 @@ org.springframework.boot spring-boot-starter-parent - 1.5.1.RELEASE + 2.1.3.RELEASE diff --git a/springboot-mybatis-annotation/pom.xml b/springboot-mybatis-annotation/pom.xml index 77ccd980..bbaf25cf 100644 --- a/springboot-mybatis-annotation/pom.xml +++ b/springboot-mybatis-annotation/pom.xml @@ -15,7 +15,7 @@ org.springframework.boot spring-boot-starter-parent - 1.5.1.RELEASE + 2.1.3.RELEASE diff --git a/springboot-mybatis-mutil-datasource/pom.xml b/springboot-mybatis-mutil-datasource/pom.xml index bc14a538..90fb8acd 100755 --- a/springboot-mybatis-mutil-datasource/pom.xml +++ b/springboot-mybatis-mutil-datasource/pom.xml @@ -12,7 +12,7 @@ org.springframework.boot spring-boot-starter-parent - 1.5.1.RELEASE + 2.1.3.RELEASE diff --git a/springboot-mybatis-redis-annotation/pom.xml b/springboot-mybatis-redis-annotation/pom.xml index 3199297f..a608e8d5 100755 --- a/springboot-mybatis-redis-annotation/pom.xml +++ b/springboot-mybatis-redis-annotation/pom.xml @@ -12,7 +12,7 @@ org.springframework.boot spring-boot-starter-parent - 1.5.3.RELEASE + 2.1.3.RELEASE diff --git a/springboot-mybatis-redis/pom.xml b/springboot-mybatis-redis/pom.xml index 21a30fcd..ef9f1656 100755 --- a/springboot-mybatis-redis/pom.xml +++ b/springboot-mybatis-redis/pom.xml @@ -12,7 +12,7 @@ org.springframework.boot spring-boot-starter-parent - 1.5.1.RELEASE + 2.1.3.RELEASE diff --git a/springboot-mybatis/pom.xml b/springboot-mybatis/pom.xml index f309b20f..62b4d14c 100755 --- a/springboot-mybatis/pom.xml +++ b/springboot-mybatis/pom.xml @@ -12,7 +12,7 @@ org.springframework.boot spring-boot-starter-parent - 1.5.1.RELEASE + 2.1.3.RELEASE diff --git a/springboot-properties/pom.xml b/springboot-properties/pom.xml index c8356620..81fe664d 100755 --- a/springboot-properties/pom.xml +++ b/springboot-properties/pom.xml @@ -12,7 +12,7 @@ org.springframework.boot spring-boot-starter-parent - 1.5.1.RELEASE + 2.1.3.RELEASE @@ -42,4 +42,24 @@ test + + + + + + org.springframework.boot + spring-boot-maven-plugin + 2.1.3.RELEASE + + + org.apache.maven.plugins + maven-surefire-plugin + 2.12.4 + + true + + + + + diff --git a/springboot-restful/pom.xml b/springboot-restful/pom.xml index 5bfce9e5..485b6f9c 100755 --- a/springboot-restful/pom.xml +++ b/springboot-restful/pom.xml @@ -12,7 +12,7 @@ org.springframework.boot spring-boot-starter-parent - 1.5.1.RELEASE + 2.1.3.RELEASE diff --git a/springboot-validation-over-json/pom.xml b/springboot-validation-over-json/pom.xml index a39b50b6..aaf48f0a 100755 --- a/springboot-validation-over-json/pom.xml +++ b/springboot-validation-over-json/pom.xml @@ -12,7 +12,7 @@ org.springframework.boot spring-boot-starter-parent - 1.5.1.RELEASE + 2.1.3.RELEASE diff --git a/springboot-webflux-1-quickstart/pom.xml b/springboot-webflux-1-quickstart/pom.xml index 6e824851..3b582640 100755 --- a/springboot-webflux-1-quickstart/pom.xml +++ b/springboot-webflux-1-quickstart/pom.xml @@ -11,7 +11,7 @@ org.springframework.boot spring-boot-starter-parent - 2.0.1.RELEASE + 2.1.3.RELEASE diff --git a/springboot-webflux-10-book-manage-sys/pom.xml b/springboot-webflux-10-book-manage-sys/pom.xml index 9b98898b..4a99ddd5 100644 --- a/springboot-webflux-10-book-manage-sys/pom.xml +++ b/springboot-webflux-10-book-manage-sys/pom.xml @@ -13,7 +13,7 @@ org.springframework.boot spring-boot-starter-parent - 2.0.1.RELEASE + 2.1.3.RELEASE diff --git a/springboot-webflux-2-restful/pom.xml b/springboot-webflux-2-restful/pom.xml index aa189d4f..e75d309f 100755 --- a/springboot-webflux-2-restful/pom.xml +++ b/springboot-webflux-2-restful/pom.xml @@ -12,7 +12,7 @@ org.springframework.boot spring-boot-starter-parent - 2.0.1.RELEASE + 2.1.3.RELEASE diff --git a/springboot-webflux-3-mongodb/pom.xml b/springboot-webflux-3-mongodb/pom.xml index d5004d84..035c5f2c 100755 --- a/springboot-webflux-3-mongodb/pom.xml +++ b/springboot-webflux-3-mongodb/pom.xml @@ -12,7 +12,7 @@ org.springframework.boot spring-boot-starter-parent - 2.0.1.RELEASE + 2.1.3.RELEASE diff --git a/springboot-webflux-4-thymeleaf/pom.xml b/springboot-webflux-4-thymeleaf/pom.xml index 2c437ce4..ae8fe1d0 100755 --- a/springboot-webflux-4-thymeleaf/pom.xml +++ b/springboot-webflux-4-thymeleaf/pom.xml @@ -12,7 +12,7 @@ org.springframework.boot spring-boot-starter-parent - 2.0.1.RELEASE + 2.1.3.RELEASE diff --git a/springboot-webflux-5-thymeleaf-mongodb/pom.xml b/springboot-webflux-5-thymeleaf-mongodb/pom.xml index 64c611d4..d64bb72b 100755 --- a/springboot-webflux-5-thymeleaf-mongodb/pom.xml +++ b/springboot-webflux-5-thymeleaf-mongodb/pom.xml @@ -12,7 +12,7 @@ org.springframework.boot spring-boot-starter-parent - 2.0.1.RELEASE + 2.1.3.RELEASE diff --git a/springboot-webflux-6-redis/pom.xml b/springboot-webflux-6-redis/pom.xml index 8f68262a..4cc6dc3c 100755 --- a/springboot-webflux-6-redis/pom.xml +++ b/springboot-webflux-6-redis/pom.xml @@ -12,7 +12,7 @@ org.springframework.boot spring-boot-starter-parent - 2.0.1.RELEASE + 2.1.3.RELEASE diff --git a/springboot-webflux-7-redis-cache/pom.xml b/springboot-webflux-7-redis-cache/pom.xml index ddc1fdb9..3609e4d8 100755 --- a/springboot-webflux-7-redis-cache/pom.xml +++ b/springboot-webflux-7-redis-cache/pom.xml @@ -12,7 +12,7 @@ org.springframework.boot spring-boot-starter-parent - 2.0.1.RELEASE + 2.1.3.RELEASE diff --git a/springboot-webflux-8-websocket/pom.xml b/springboot-webflux-8-websocket/pom.xml index c141f781..109c35ab 100755 --- a/springboot-webflux-8-websocket/pom.xml +++ b/springboot-webflux-8-websocket/pom.xml @@ -11,7 +11,7 @@ org.springframework.boot spring-boot-starter-parent - 2.0.1.RELEASE + 2.1.3.RELEASE diff --git a/springboot-webflux-9-test/pom.xml b/springboot-webflux-9-test/pom.xml index 24d9a2b0..1132904a 100755 --- a/springboot-webflux-9-test/pom.xml +++ b/springboot-webflux-9-test/pom.xml @@ -12,7 +12,7 @@ org.springframework.boot spring-boot-starter-parent - 2.0.1.RELEASE + 2.1.3.RELEASE