Skip to content

Commit

Permalink
SpringBoot2 整合 ClickHouse数据库,实现数据高性能查询分析
Browse files Browse the repository at this point in the history
  • Loading branch information
cicadasmile committed Oct 7, 2019
1 parent 0170734 commit 437fea5
Show file tree
Hide file tree
Showing 15 changed files with 424 additions and 12 deletions.
26 changes: 14 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,42 @@
<b>【案例中相关中间件搭建】--> 【[GitHub点这里](https://github.com/cicadasmile/linux-system-base)】 【[码云.点这里](https://gitee.com/cicadasmile/linux-system-base)】</b><br/>

<a href="https://mp.weixin.qq.com/s?__biz=MzU4Njg0MzYwNw==&mid=2247483713&idx=1&sn=cd4228e19d07e0371af7ef06515f4298&chksm=fdf455f9ca83dcef81c44f10bff15a3d3a29553746eef9cad9d4e2a13c5d5709d95a375bff0a&token=949711998&lang=zh_CN#rd">
01、SpringBoot2.0 整合 shard-jdbc 中间件,实现数据分库分表</a><br/>
01、SpringBoot2 整合 shard-jdbc 中间件,实现数据分库分表</a><br/>

<a href="https://mp.weixin.qq.com/s?__biz=MzU4Njg0MzYwNw==&mid=2247483740&idx=1&sn=807e5372f14daa59220adecd0f0dc56d&chksm=fdf455e4ca83dcf2632bcf9144a6553e7e16f0ba46a9b59cb21085da05663467d90ad885528c&token=261735462&lang=zh_CN#rd">
02、SpringBoot2.0 整合 JavaMail ,实现异步发送邮件功能</a><br/>
02、SpringBoot2 整合 JavaMail ,实现异步发送邮件功能</a><br/>

<a href="https://mp.weixin.qq.com/s?__biz=MzU4Njg0MzYwNw==&mid=2247483755&idx=1&sn=9d78e7714ad4621fe5e643593069b186&chksm=fdf455d3ca83dcc5cdfa29de2dab4fee7595fc80a6d73f72cc782591e87c3ac296977daa6bc8&token=261735462&lang=zh_CN#rd">
03、SpringBoot2.0 整合 RocketMQ ,实现请求异步处理</a><br/>
03、SpringBoot2 整合 RocketMQ ,实现请求异步处理</a><br/>

<a href="https://mp.weixin.qq.com/s?__biz=MzU4Njg0MzYwNw==&mid=2247483767&idx=1&sn=fc845a2fb0ee7768946f8739101ac2aa&chksm=fdf455cfca83dcd9de4bac70f6cfa9a88907cdbb4ec7b0c2da13e65efc1a2564eb6599d38bc8&token=261735462&lang=zh_CN#rd">
04、SpringBoot2.0 整合 Swagger2 ,构建接口管理界面</a><br/>
04、SpringBoot2 整合 Swagger2 ,构建接口管理界面</a><br/>

<a href="https://mp.weixin.qq.com/s?__biz=MzU4Njg0MzYwNw==&mid=2247483774&idx=1&sn=e5c2eed4a989bedd5c3b108c7dc18c37&chksm=fdf455c6ca83dcd0bccf71aa07639b8ef514e3b6e6d85c6aeb4bceae30d58f021c9d7ba8590b&token=261735462&lang=zh_CN#rd">
05、SpringBoot2.0 整合 QuartJob ,实现定时器实时管理</a><br/>
05、SpringBoot2 整合 QuartJob ,实现定时器实时管理</a><br/>

<a href="https://mp.weixin.qq.com/s?__biz=MzU4Njg0MzYwNw==&mid=2247483886&idx=1&sn=2158323687acc7713d5d45c21c9558ee&chksm=fdf45556ca83dc409f1c7ce282b4297a0bed9df594796fd921c719f0c77896a183098cb43159&token=872954754&lang=zh_CN#rd">
06、SpringBoot2.0 整合 Redis集群 ,实现消息队列场景</a><br/>
06、SpringBoot2 整合 Redis集群 ,实现消息队列场景</a><br/>

<a href="https://mp.weixin.qq.com/s?__biz=MzU4Njg0MzYwNw==&mid=2247483895&idx=1&sn=4fdc2a307b49a66c37c22c7de62aa323&chksm=fdf4554fca83dc5935e3f36c541a5e03cedd440e14eafa1a577b52f047d98b79b9af891f7330&token=989276463&lang=zh_CN#rd">
07、SpringBoot2.0 整合 Dubbo框架 ,实现RPC服务远程调用</a><br/>
07、SpringBoot2 整合 Dubbo框架 ,实现RPC服务远程调用</a><br/>

<a href="https://mp.weixin.qq.com/s?__biz=MzU4Njg0MzYwNw==&mid=2247483905&idx=1&sn=f15ecc1ab3065c24854a02741db0aa0c&chksm=fdf456b9ca83dfaf937f370981432f98d2c5d7d0c7638df6206ffd22c2db79b7924c19e90931&token=935482848&lang=zh_CN#rd">
08、SpringBoot2.0 整合 ElasticSearch框架,实现高性能搜索引擎</a><br/>
08、SpringBoot2 整合 ElasticSearch框架,实现高性能搜索引擎</a><br/>

<a href="https://mp.weixin.qq.com/s?__biz=MzU4Njg0MzYwNw==&mid=2247483909&idx=1&sn=e7a63b160abfd623222a2eb089c3bbce&chksm=fdf456bdca83dfab1feea56ba01a956eee764fd84ae6a198b805458adbb94e5abe5488704186&token=838095302&lang=zh_CN#rd">
09、SpringBoot2.0 整合 JWT 框架,解决Token跨域验证问题</a><br/>
09、SpringBoot2 整合 JWT 框架,解决Token跨域验证问题</a><br/>

<a href="https://mp.weixin.qq.com/s?__biz=MzU4Njg0MzYwNw==&mid=2247483918&idx=1&sn=189b6f4360c46ca816de85a3205a9fb3&chksm=fdf456b6ca83dfa0f5b0f9c441a8ece1b158792a03e3483ddc702576e9e77f963690c0716e9f&token=1681245262&lang=zh_CN#rd">
10、SpringBoot2.0 整合 FastDFS 中间件,实现文件分布管理</a><br/>
10、SpringBoot2 整合 FastDFS 中间件,实现文件分布管理</a><br/>

<a href="https://mp.weixin.qq.com/s?__biz=MzU4Njg0MzYwNw==&mid=2247483922&idx=1&sn=f632615588b11840df3a6d17013c7058&chksm=fdf456aaca83dfbc34e13ffd4f05491e6598f3eff7bfeab28b14317cc0f95f939de08eee0c1e&token=1211663505&lang=zh_CN#rd">
11、SpringBoot2.0 整合 Shiro 框架,实现用户权限管理</a><br/>
11、SpringBoot2 整合 Shiro 框架,实现用户权限管理</a><br/>

<a href="https://mp.weixin.qq.com/s?__biz=MzU4Njg0MzYwNw==&mid=2247483938&idx=1&sn=f923b53798f480960862f44ee044ec12&chksm=fdf4569aca83df8c32f49cc1f9d2d9066bb497b2d3fa45ecf97b2e22edaea6e09e405636282e&token=1000382877&lang=zh_CN#rd">
12、SpringBoot2.0 整合 Security 框架,实现用户权限管理</a><br/>
12、SpringBoot2 整合 Security 框架,实现用户权限管理</a><br/>

[13、SpringBoot2 整合 ClickHouse数据库,实现数据高性能查询分析](https://mp.weixin.qq.com/s?__biz=MzU4Njg0MzYwNw==&mid=2247484121&idx=1&sn=29cc633facbbb2c69afa4e6472fb93e8&chksm=fdf45661ca83df77879cbea0e0e3b445a5972a9fc0f84ae25c6882e60e4bed3dc2a68338fa2a&token=1150397377&lang=zh_CN#rd)<br/>

持续更新中...

Expand Down
2 changes: 2 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
<module>ware-shiro-auth</module>
<!-- Security 权限管理 -->
<module>ware-security-auth</module>
<!-- ClickHouse 数据库 -->
<module>ware-click-house</module>
</modules>

<!-- 依赖版本管理 -->
Expand Down
76 changes: 76 additions & 0 deletions ware-click-house/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?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">
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starters</artifactId>
<version>2.1.3.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.click.house</groupId>
<artifactId>ware-click-house</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.38</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.13</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<!-- clickHouse数据库 -->
<dependency>
<groupId>ru.yandex.clickhouse</groupId>
<artifactId>clickhouse-jdbc</artifactId>
<version>0.1.53</version>
</dependency>
</dependencies>
<!-- 项目构建 -->
<build>
<finalName>${project.artifactId}</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.click.house;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@MapperScan(basePackages = {"com.click.house.mapper"})
public class Application7016 {
public static void main(String[] args) {
SpringApplication.run(Application7016.class,args) ;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.click.house.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.annotation.Resource;
import javax.sql.DataSource;

@Configuration
public class DruidConfig {

@Resource
private JdbcParamConfig jdbcParamConfig ;

@Bean
public DataSource dataSource() {
DruidDataSource datasource = new DruidDataSource();
datasource.setUrl(jdbcParamConfig.getUrl());
datasource.setDriverClassName(jdbcParamConfig.getDriverClassName());
datasource.setInitialSize(jdbcParamConfig.getInitialSize());
datasource.setMinIdle(jdbcParamConfig.getMinIdle());
datasource.setMaxActive(jdbcParamConfig.getMaxActive());
datasource.setMaxWait(jdbcParamConfig.getMaxWait());
return datasource;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.click.house.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Component
@ConfigurationProperties(prefix = "spring.datasource.click")
public class JdbcParamConfig {

private String driverClassName ;
private String url ;
private Integer initialSize ;
private Integer maxActive ;
private Integer minIdle ;
private Integer maxWait ;
public String getDriverClassName() {
return driverClassName;
}
public void setDriverClassName(String driverClassName) {
this.driverClassName = driverClassName;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public Integer getInitialSize() {
return initialSize;
}
public void setInitialSize(Integer initialSize) {
this.initialSize = initialSize;
}
public Integer getMaxActive() {
return maxActive;
}
public void setMaxActive(Integer maxActive) {
this.maxActive = maxActive;
}
public Integer getMinIdle() {
return minIdle;
}
public void setMinIdle(Integer minIdle) {
this.minIdle = minIdle;
}
public Integer getMaxWait() {
return maxWait;
}
public void setMaxWait(Integer maxWait) {
this.maxWait = maxWait;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.click.house.controller;

import com.click.house.entity.UserInfo;
import com.click.house.service.UserInfoService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/user")
public class UserInfoController {
@Resource
private UserInfoService userInfoService ;
@RequestMapping("/saveData")
public String saveData (){
UserInfo userInfo = new UserInfo () ;
userInfo.setId(4);
userInfo.setUserName("winter");
userInfo.setPassWord("567");
userInfo.setPhone("13977776789");
userInfo.setEmail("winter");
userInfo.setCreateDay("2020-02-20");
userInfoService.saveData(userInfo);
return "sus";
}
@RequestMapping("/selectById")
public UserInfo selectById () {
return userInfoService.selectById(1) ;
}
@RequestMapping("/selectList")
public List<UserInfo> selectList () {
return userInfoService.selectList() ;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.click.house.entity;

public class UserInfo {

private Integer id ;
private String userName ;
private String passWord ;
private String phone ;
private String email ;
private String createDay ;

public Integer getId() {
return id;
}

public void setId(Integer id) {
this.id = id;
}

public String getUserName() {
return userName;
}

public void setUserName(String userName) {
this.userName = userName;
}

public String getPassWord() {
return passWord;
}

public void setPassWord(String passWord) {
this.passWord = passWord;
}

public String getPhone() {
return phone;
}

public void setPhone(String phone) {
this.phone = phone;
}

public String getEmail() {
return email;
}

public void setEmail(String email) {
this.email = email;
}

public String getCreateDay() {
return createDay;
}

public void setCreateDay(String createDay) {
this.createDay = createDay;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.click.house.mapper;

import com.click.house.entity.UserInfo;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface UserInfoMapper {
// 写入数据
void saveData (UserInfo userInfo) ;
// ID 查询
UserInfo selectById (@Param("id") Integer id) ;
// 查询全部
List<UserInfo> selectList () ;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.click.house.service;

import com.click.house.entity.UserInfo;

import java.util.List;

public interface UserInfoService {
// 写入数据
void saveData (UserInfo userInfo) ;
// ID 查询
UserInfo selectById (Integer id) ;
// 查询全部
List<UserInfo> selectList () ;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.click.house.service.impl;

import com.click.house.entity.UserInfo;
import com.click.house.mapper.UserInfoMapper;
import com.click.house.service.UserInfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserInfoServiceImpl implements UserInfoService {

@Resource
private UserInfoMapper userInfoMapper ;

@Override
public void saveData(UserInfo userInfo) {
userInfoMapper.saveData(userInfo);
}

@Override
public UserInfo selectById(Integer id) {
return userInfoMapper.selectById(id);
}

@Override
public List<UserInfo> selectList() {
return userInfoMapper.selectList();
}
}
Loading

0 comments on commit 437fea5

Please sign in to comment.