phoenix-mybatis-plus-starter

Mybatis Plus Phoenix Starter Project For Spring Boot

License

License

Categories

Categories

MyBatis Data ORM
GroupId

GroupId

com.github.flyingglass
ArtifactId

ArtifactId

phoenix-mybatis-plus-starter
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

phoenix-mybatis-plus-starter
Mybatis Plus Phoenix Starter Project For Spring Boot
Source Code Management

Source Code Management

https://github.com/FlyingGlass/phoenix-mybatis-plus-starter

Download phoenix-mybatis-plus-starter

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.flyingglass/phoenix-mybatis-plus-starter/ -->
<dependency>
    <groupId>com.github.flyingglass</groupId>
    <artifactId>phoenix-mybatis-plus-starter</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.flyingglass/phoenix-mybatis-plus-starter/
implementation 'com.github.flyingglass:phoenix-mybatis-plus-starter:1.0.0'
// https://jarcasting.com/artifacts/com.github.flyingglass/phoenix-mybatis-plus-starter/
implementation ("com.github.flyingglass:phoenix-mybatis-plus-starter:1.0.0")
'com.github.flyingglass:phoenix-mybatis-plus-starter:jar:1.0.0'
<dependency org="com.github.flyingglass" name="phoenix-mybatis-plus-starter" rev="1.0.0">
  <artifact name="phoenix-mybatis-plus-starter" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.flyingglass', module='phoenix-mybatis-plus-starter', version='1.0.0')
)
libraryDependencies += "com.github.flyingglass" % "phoenix-mybatis-plus-starter" % "1.0.0"
[com.github.flyingglass/phoenix-mybatis-plus-starter "1.0.0"]

Dependencies

compile (2)

Group / Artifact Type Version
org.projectlombok : lombok Optional jar
com.baomidou : mybatis-plus-boot-starter jar 3.2.0

Project Modules

There are no modules declared in this project.

phoenix-mybatis-plus-starter

简介

该项目主要利用SpringBoot的自动化配置特性来实现快速的将Mybatis-Plus + Phoenix引入Springboot项目中,简化原生Mybatis-Plus整合Phoenix使用。

欢迎使用和star支持,如使用中碰到问题,可以提出Issue,我会尽力完善该Starter

版本基础

  • Mybatis-Plus: 3.2.0
  • Spring-Boot: 2.2.2.RELEASE

Quick-Start

轻松引入SpringBoot工程中,需要如下步骤:

  • pom.xml中引入依赖:
<dependency>
    <groupId>com.github.flyingglass</groupId>
    <artifactId>phoenix-mybatis-plus-starter</artifactId>
    <version>1.0.0</version>
</dependency>
  • 在应用主类中增加@MapperScan(basePackages = "com.xxx.mapper")注解,用于扫描MapperInterface,并且排除DruidDataSourceAutoConfigure
@MapperScan(basePackages = "com.xxx.mapper")
@SpringBootApplication(
        exclude = DruidDataSourceAutoConfigure.class
)
public class Bootstrap {

    public static void main(String[] args) {
        SpringApplication.run(Bootstrap.class, args);
    }

}
  • 配置application.yml

配置phoenix数据源,已针对phoenix-core进行shaded repackage解决Springboot兼容问题

  • 配置pom.xml
<dependency>
    <groupId>com.github.flyingglass</groupId>
    <artifactId>phoenix-core-shaded</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <exclusions>
        <exclusion>
            <groupId>org.apache.phoenix</groupId>
            <artifactId>phoenix-core</artifactId>
        </exclusion>
    </exclusions>
</dependency>

<dependency>
    <groupId>com.github.flyingglass</groupId>
    <artifactId>hbase-client-shaded</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <exclusions>
        <exclusion>
            <groupId>org.apache.hbase</groupId>
            <artifactId>hbase-client</artifactId>
        </exclusion>
    </exclusions>
</dependency>
  • 配置application.yml
spring:
  datasource:
    dynamic:
      primary: master
      datasource:
        master:
          username:
          password:
          url: jdbc:phoenix:znode01,znode02,znode03:2181
          driver-class-name: org.apache.phoenix.jdbc.PhoenixDriver
          druid:
            filters: stat
            connection-properties:
              schema: "\"TEST\""

自定义特性

  • 通过Mybatis-plusSqlInjector注入PhoenixUpsertupsert方法适应phoenix插入方法
  • 自定义IPhoenixService,用户的Service继承自PhoenixServiceImpl即可复用Mybatis-plusServiceImpl<M, T>所有方法
  • 关于PhoenixHBase的版本兼容问题,对于包冲突,需要额外shaded repackage,参考:https://github.com/FlyingGlass/hbase-phoenix-shaded

Versions

Version
1.0.0