最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

使用MyBatis從hive中讀取數(shù)據(jù)

 更新時(shí)間:2024年05月08日 10:29:49   作者:amadeus_liu2  
Hive是一個(gè)基于Hadoop的數(shù)據(jù)倉庫工具,它可以方便地對(duì)大規(guī)模數(shù)據(jù)進(jìn)行查詢和分析,本文主要介紹了使用MyBatis從hive中讀取數(shù)據(jù),具有一定的參考價(jià)值,感興趣的可以了解一下

一、hive表:

在這里插入圖片描述

啟動(dòng)hiveserver2

二、添加mybatis starter和hive依賴

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>hivejdbc</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.6.6</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>1.3.1</version>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>


        <dependency>
            <groupId>org.apache.hive</groupId>
            <artifactId>hive-jdbc</artifactId>
            <version>2.1.1</version>
            <exclusions>
                <exclusion>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-runner</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.hive/hive-exec -->
        <dependency>
            <groupId>org.apache.hive</groupId>
            <artifactId>hive-exec</artifactId>
            <version>3.0.0</version>
        </dependency>
        
    </dependencies>

</project>

三、配置文件application.properties中配置數(shù)據(jù)源:

server.port=9202
spring.datasource.driverClassName=org.apache.hive.jdbc.HiveDriver
spring.datasource.url=jdbc:hive2://xx.xx.xx.xx:10000/default
spring.datasource.username=
spring.datasource.password=

四、定義mapper

package cn.edu.tju.mapper;

import cn.edu.tju.domain.UserInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface UserInfoMapper {
    @Select("select * from userinfo")
    List<Map<String,Object>> getUserList();


}

五、定義controller,注入mapper并使用

package cn.edu.tju.controller;

import cn.edu.tju.domain.UserInfo;
import cn.edu.tju.mapper.UserInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
public class UserInfoController {
    @Autowired
    private UserInfoMapper userInfoMapper;

    @RequestMapping("/getUserInfo")
    public String getUserInfo() {
        List<Map<String, Object>> userList = userInfoMapper.getUserList();
        int size = userList.size();
        //System.out.println(size);
        for (int i = 0; i < size; i ++ ){
            Map userInfo = (Map)userList.get(i).get("userinfo");
            System.out.println(userInfo.get("x"));
            System.out.println(userInfo.get("y"));
        }

            return "ok";
    }


}

到此這篇關(guān)于使用MyBatis從hive中讀取數(shù)據(jù)的文章就介紹到這了,更多相關(guān)MyBatis hive讀取內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家! 

相關(guān)文章

  • springboot操作靜態(tài)資源文件的方法

    springboot操作靜態(tài)資源文件的方法

    這篇文章主要介紹了springboot操作靜態(tài)資源文件的方法,本文給大家提到了兩種方法,小編在這里比較推薦第一種方法,具體內(nèi)容詳情大家跟隨腳本之家小編一起看看吧
    2018-07-07
  • 深入了解java中的string對(duì)象

    深入了解java中的string對(duì)象

    這篇文章主要介紹了java中的string對(duì)象,String對(duì)象是Java中使用最頻繁的對(duì)象之一,所以Java開發(fā)者們也在不斷地對(duì)String對(duì)象的實(shí)現(xiàn)進(jìn)行優(yōu)化,以便提升String對(duì)象的性能。對(duì)此感興趣的朋友跟隨小編一起看看吧
    2019-11-11
  • java:Apache Commons Configuration2占位符使用方式

    java:Apache Commons Configuration2占位符使用方式

    Apache Commons Configuration2中的占位符功能允許在配置值中引用其他配置屬性或外部值,通過`${前綴:鍵名}`格式實(shí)現(xiàn),它提供了多種默認(rèn)的Lookup實(shí)現(xiàn),如base64編碼/解碼、日期格式化、環(huán)境變量、文件讀取等,此外,還支持自定義占位符實(shí)現(xiàn),以滿足特定需求
    2025-12-12
  • SpringBoot3集成swagger文檔的使用方法

    SpringBoot3集成swagger文檔的使用方法

    本文介紹了Swagger的誕生背景、主要功能以及如何在Spring Boot 3中集成Swagger文檔,Swagger可以幫助自動(dòng)生成API文檔,實(shí)現(xiàn)與代碼同步,并提供交互式測(cè)試功能,使用方法包括導(dǎo)入依賴、配置文檔、使用常見注解以及訪問生成的Swagger UI和文檔,感興趣的朋友跟隨小編一起看看吧
    2025-01-01
  • Spring?Boot整合阿里開源中間件Canal實(shí)現(xiàn)數(shù)據(jù)增量同步

    Spring?Boot整合阿里開源中間件Canal實(shí)現(xiàn)數(shù)據(jù)增量同步

    這篇文章主要為大家介紹了Spring?Boot整合阿里開源中間件Canal實(shí)現(xiàn)數(shù)據(jù)增量同步示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-06-06
  • java發(fā)送郵件示例講解

    java發(fā)送郵件示例講解

    這篇文章主要為大家詳細(xì)介紹了java發(fā)送郵件示例的全過程,溫習(xí)郵件協(xié)議,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-03-03
  • SpringBoot+MyBatis進(jìn)行XML中循環(huán)處理List參數(shù)的終極指南

    SpringBoot+MyBatis進(jìn)行XML中循環(huán)處理List參數(shù)的終極指南

    這篇文章主要為大家詳細(xì)介紹了SpringBoot整合MyBatis進(jìn)行XML中循環(huán)處理List參數(shù)的相關(guān)知識(shí),文中的示例代碼講解詳細(xì),感興趣的小伙伴可以了解下
    2025-07-07
  • Java NIO實(shí)戰(zhàn)之聊天室功能詳解

    Java NIO實(shí)戰(zhàn)之聊天室功能詳解

    這篇文章主要介紹了Java NIO實(shí)戰(zhàn)之聊天室功能,結(jié)合實(shí)例形式詳細(xì)分析了java NIO聊天室具體的服務(wù)端、客戶端相關(guān)實(shí)現(xiàn)方法與操作注意事項(xiàng),需要的朋友可以參考下
    2019-11-11
  • Maven構(gòu)建時(shí)跳過部分測(cè)試的實(shí)例

    Maven構(gòu)建時(shí)跳過部分測(cè)試的實(shí)例

    下面小編就為大家分享一篇Maven構(gòu)建時(shí)跳過部分測(cè)試的實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助
    2017-11-11
  • 自己動(dòng)手在Spring-Boot上加強(qiáng)國際化功能的示例

    自己動(dòng)手在Spring-Boot上加強(qiáng)國際化功能的示例

    這篇文章主要介紹了自己動(dòng)手在Spring-Boot上加強(qiáng)國際化功能的示例,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2018-04-04

最新評(píng)論

德庆县| 同德县| 沙田区| 广东省| 定远县| 万山特区| 临湘市| 贵南县| 马边| 吉安县| 贺州市| 阿勒泰市| 开阳县| 西畴县| 万州区| 五华县| 十堰市| 修文县| 天全县| 盈江县| 浦城县| 房山区| 马尔康县| 佛冈县| 兴国县| 汾阳市| 荔波县| 晋江市| 江孜县| 同江市| 江口县| 郎溪县| 蒲江县| 大洼县| 万宁市| 镇赉县| 康马县| 报价| 上蔡县| 蓝田县| 平乡县|