(demo)springboot接口suger_整合_hbase+phoenix
依赖
<properties><java.version>1.8</java.version><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding><spring-boot.version>2.3.7.RELEASE</spring-boot.version> </properties><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>com.alibaba</groupId><artifactId>druid</artifactId><version>1.1.14</version></dependency><dependency><groupId>org.apache.hadoop</groupId><artifactId>hadoop-client</artifactId><version>3.2.0</version><exclusions><exclusion><groupId>org.slf4jgroupId</groupId><artifactId>slf4j-log4j12artifactId</artifactId></exclusion></exclusions></dependency><dependency><groupId>org.apache.phoenix</groupId><artifactId>phoenix-core</artifactId><version>5.0.0-HBase-2.0</version><exclusions><exclusion><groupId>org.slf4jgroupId</groupId><artifactId>slf4j-log4j12artifactId</artifactId></exclusion><exclusion><groupId>log4jgroupId</groupId><artifactId>log4jartifactId</artifactId></exclusion></exclusions></dependency><dependency><groupId>log4j</groupId><artifactId>log4j</artifactId><version>1.2.17</version></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><optional>true</optional></dependency><dependency><groupId>org.mybatis.spring.boot</groupId><artifactId>mybatis-spring-boot-starter</artifactId><version>2.1.4</version></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope><exclusions><exclusion><groupId>org.junit.vintage</groupId><artifactId>junit-vintage-engine</artifactId></exclusion></exclusions></dependency><dependency><groupId>com.alibaba</groupId><artifactId>fastjson</artifactId><version>1.2.68</version></dependency> </dependencies><dependencyManagement><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-dependencies</artifactId><version>${spring-boot.version}</version><type>pom</type><scope>import</scope></dependency></dependencies> </dependencyManagement><build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.8.1</version><configuration><source>1.8</source><target>1.8</target><encoding>UTF-8</encoding></configuration></plugin><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><version>2.3.7.RELEASE</version><configuration><mainClass>com.example.demo.DemoApplication</mainClass></configuration><executions><execution><id>repackage</id><goals><goal>repackage</goal></goals></execution></executions></plugin></plugins> </build>
从服务器hbase安装目录下拷贝hbase-site.xml到resources目录下,我的是:
<?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <!-- /**** Licensed to the Apache Software Foundation (ASF) under one* or more contributor license agreements. See the NOTICE file* distributed with this work for additional information* regarding copyright ownership. The ASF licenses this file* to you under the Apache License, Version 2.0 (the* "License"); you may not use this file except in compliance* with the License. You may obtain a copy of the License at** http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.* See the License for the specific language governing permissions and* limitations under the License.*/ --> <configuration><!-- HBase数据在HDFS中的存放的路径 --><property><name>hbase.rootdir</name><value>hdfs://hadoop101:8020/hbase</value></property><!-- Hbase的运行模式。false是单机模式,true是分布式模式。若为false,Hbase和Zookeeper会运行在同一个JVM里面 --><property><name>hbase.cluster.distributed</name><value>true</value></property><!-- ZooKeeper的地址 --><property><name>hbase.zookeeper.quorum</name><value>hadoop101,hadoop102,hadoop103</value></property><!-- ZooKeeper快照的存储位置 --><property><name>hbase.zookeeper.property.dataDir</name><value>/opt/module/zookeeper-3.5.7/zkData/</value></property><!-- V2.1版本,在分布式情况下, 设置为false 将非安全检查设置成false--><property><name>hbase.unsafe.stream.capability.enforce</name><value>false</value></property><property><name>phoenix.schema.isNamespaceMappingEnabled</name><value>true</value></property><property><name>phoenix.schema.mapSystemTablesToNamespace</name><value>true</value></property><!-- 支持索引预写日志编码 --><property><name>hbase.regionserver.wal.codec</name><value>org.apache.hadoop.hbase.regionserver.wal.IndexedWALEditCodec</value></property><!-- phoenix regionserver 配置参数--><property><name>hbase.regionserver.wal.codec</name><value>org.apache.hadoop.hbase.regionserver.wal.IndexedWALEditCodec</value></property><property><name>hbase.region.server.rpc.scheduler.factory.class</name><value>org.apache.hadoop.hbase.ipc.PhoenixRpcSchedulerFactory</value><description>Factory to create the Phoenix RPC Scheduler that uses separate queues for index and metadata updates</description></property><property><name>hbase.rpc.controllerfactory.class</name><value>org.apache.hadoop.hbase.ipc.controller.ServerRpcControllerFactory</value><description>Factory to create the Phoenix RPC Scheduler that uses separate queues for index and metadata updates</description> </property> </configuration>
修改application.properties文件添加配置信息
# 应用名称 # 应用服务 WEB 访问端口 server.port=8080# datasource spring.datasource.driver-class-name=org.apache.phoenix.jdbc.PhoenixDriver spring.datasource.url=jdbc:phoenix:hadoop101:2181 spring.datasource.type=com.alibaba.druid.pool.DruidDataSource spring.datasource.data-username= spring.datasource.data-password=# mybatis mybatis.typeAliasesPackage=com.example.demp.entity mybatis.mapperLocations=classpath:mapper/*.xml mybatis.configuration.map-underscore-to-camel-case=truelogging.level.com.example.phoenix.mapper=debug
在resources.mapper 路径下添加配置文件Mapper.xml,写SQL:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapperPUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.example.demo.mapper.BiMapper"><select id="list" resultType="com.example.demo.entity.Stu">select * from "STU"</select> </mapper>
启动类DemoApplication也要加上注解:
package com.example.demo;import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplication @MapperScan("com.example.demo.mapper") public class DemoApplication {public static void main(String[] args) {SpringApplication.run(DemoApplication.class, args);}}
完成这些基本的配置之后:开始mapper \ service \ controller 首先是mapper :
public interface BiMapper {List list(); }
然后是service层(接口):
public interface BiService {List list(); }
实现类:
@Service public class BiServiceImpl implements BiService {@ResourceBiMapper mapper;@Overridepublic List list() {return mapper.list();} }
最后是controller层:
@RestController @RequestMapping("/") public class BiController {@ResourceBiService service;@RequestMapping("list")public String getorder(){List list=service.list();Map<String,Object> map = new HashMap();map.put("status",0);map.put("msg","");map.put("data",list);return JSON.toJSONString(map);}}
然后通过内网穿透 把 项目的接口发布到公网,在百度的suger连接到接口,拿到信息:
具体:
我的内网穿透用的是natApp:
开启之后:登陆suger选择模板:
数据绑定方式 选择 ‘api绑定’:
值得一提的是,使用suger可视化json格式要对齐
可以在选静态json查看需要的格式:提前编辑好,然后再上传
写的不好,只是自己做个笔记~~
(demo)springboot接口suger_整合_hbase+phoenix相关推荐
- springboot mybatis easyui 整合的一个小demo
springboot mybatis easyui 整合的一个小demo 这是最终完成界面 话不多说 开整! 这是项目结构 数据库 表结构和数据库 (有点乱 之前本来是个正经图书表的 = =.) /* ...
- SpringBoot 实战 (九) | 整合 Mybatis
微信公众号:一个优秀的废人 如有问题或建议,请后台留言,我会尽力解决你的问题. 前言 如题,今天介绍 SpringBoot 与 Mybatis 的整合以及 Mybatis 的使用,本文通过注解的形式实 ...
- 玩转 SpringBoot 2 之整合 JWT 上篇
前言 该文主要带你了解什么是 JWT,以及JWT 定义和先关概念的介绍,并通过简单Demo 带你了解如何使用 SpringBoot 2 整合 JWT. 介绍前在这里我们来探讨一下如何学习一门新的技术, ...
- springboot低版本整合knife4j
springboot低版本整合knife4j 参考网址: knife4j的gitee仓库 https://search.gitee.com/?skin=rec&type=repository& ...
- IDEA创建一个springboot项目(三)整合swagge接口测试框架
我是在上一篇的demo基础上增加的,上一篇地址:springboot项目(二)整合TKMytis框架 一:认识Swagger Swagger 是一个规范和完整的框架,用于生成.描述.调用和可视化 RE ...
- 【SpringBoot专题】整合mybatis-plus之封装查询参数简化查询
[SpringBoot专题]整合mybatis-plus之封装查询参数简化查询 通常开发过程中,操作数据库是作为后端开发必要掌握的本领,今天分享的是springboot整合mybatis-plus,官 ...
- 利用IDEA搭建SpringBoot项目,整合mybatis,实现简单的登录功能。
利用IDEA搭建SpringBoot项目,整合mybatis,实现简单的登录功能. 仅供参考!!! 仅供参考!!! 仅供参考!!! 利用闲余时间想自己搭建一个springboot+mybatis的项目 ...
- springboot接口入参下划线转驼峰以及返回参数驼峰转下划线实现
转自:springboot接口入参下划线转驼峰以及返回参数驼峰转下划线实现 - 李东平|一线码农 - 博客园 (cnblogs.com) 1.背景 在实际开发中,通常来说java里面是使用驼峰的命名规 ...
- SpringBoot实战:整合Redis、mybatis,封装RedisUtils工具类等(附源码)
创建SpringBoot项目 在线创建方式 网址:https://start.spring.io/ 然后创建Controller.Mapper.Service包 SpringBoot整合Redis 引 ...
- 玩转 SpringBoot 2 之整合定时任务篇
前言 通过本文你将了解到如何在 SpringBoot 2 中整合定时任务使用教程,具体详细内容如下: SpringBoot 自带定时任务使用教程 SpringBoot 集成 JDK 定时任务使用教程 ...
最新文章
- win10巨帧数据包在哪里设置_Win10电脑总感觉网速慢,是什么原因
- 汉诺塔(Tower of Hanoi) 递归代码实现 c语言(顺序栈实现)
- 如何查看Exchange2010中邮箱数据库的用户邮箱占用情况
- Vue表格中,对数据进行转换、处理
- G20杭州峰会上云 实现0安全事件
- HTML+CSS+JS实现 ❤️canvas酷炫表白爱心动画❤️
- python编码操作技巧总结
- 拜托!这才是分布式系统CAP的正确打开方式!
- 深度学习模型可解释性初探
- Ubuntu 默认 root 密码修改
- 解读Unity中的CG编写Shader系列二
- sqlserver2005身份验证
- [AD]-学习笔记-元件库介绍及电阻容模型和IC类器件的创建
- 纯js开发android,js开发app_安卓app开发引擎
- 神策分析 iOS SDK 全埋点解析之元素点击与页面浏览
- 使用计算机眼睛保护方法有哪些,使用电脑保护眼睛的方法有哪些
- ubuntu打开只读文件并修改
- NYOJ - 独木舟上的旅行
- 一政网好吗,考公务员报班的作用
- Android开发的单词本APP项目介绍及源码(大作业)