资源简介

这是sharding-jdbc spring boot的一个demo程序。分别使用了controller的单元测试及服务的单元测试resources / sql下的sql语句在两个不同的数据库下执行。

资源截图

代码片段和文件信息

package com.tuyu.sharding;

import com.tuyu.sharding.entity.ActionLog;
import com.tuyu.sharding.mappper.ActionLogMapper;
import com.tuyu.sharding.repository.ActionLogRepository;
import com.tuyu.sharding.service.ActionLogService;
import com.tuyu.sharding.sql.SqlMapper;
import com.tuyu.sharding.util.MyMapper;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.EnableScheduling;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.*;

@SpringBootApplication
@EnableScheduling
//@MapperScan(basePackages = “com.tuyu.sharding.mapper“markerInterface = MyMapper.class)
public class SpringBootShardingJdbcApplication{


@Autowired
ActionLogService actionLogService;

@Autowired
SqlMapper sqlMapper;

@Autowired
ActionLogRepository actionLogRepository;

@Autowired
@Qualifier(“acDataSource“)
DataSource dataSource;

// @Autowired
// ActionLogMapper actionLogMapper;

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

// @Override
// public void run(String... strings) throws Exception {
// //查询逻辑表数据——测试通过
//// actionLogService.selectAll();
// //根据时间和租户Id查找所有行为日志
//// List list = sqlMapper.selectAll(“20161226““20161227““30“);
//// for (ActionLog actionLog : list){
//// System.out.println(actionLog);
//// }
// //根据时间、租户Id进行serv排行需要自己合并,排序
//// Listject>> sorvSortlist = sqlMapper.servSortEnhance(“20161226““20161227““30“);
//// Map servSortMap = formateServOrApp(sorvSortlist“serv“);
//// List> sortList = new ArrayList>(servSortMap.entrySet());
//// Collections.sort(sortList new Comparator>() {
//// @Override
//// public int compare(Map.Entry o1 Map.Entry o2) {
//// return o2.getValue().compareTo(o1.getValue());
//// }
//// });
//// int i = 0 ;
//// Mapject> returnMap = new linkedHashMapject>();
//// for (Map.Entry entry : sortList){
//// if (i<5){
//// returnMap.put(entry.getKey()entry.getValue());
//// i++;
//// }
//// }
//// System.out.println(returnMap);
// //根据时间、租户Id对于流量的serv进行排行
//// Listject>> fluxServSortList = sqlMapper.fluxServSort(“20161226““20161227““30“);
//// for(Mapject> map : fluxServSortList){
//// System.out.println(map);
//// }
// //用户排行
//// List

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2019-02-22 16:33  spring-boot-sharding-jdbc-master\
     目录           0  2019-02-25 14:33  spring-boot-sharding-jdbc-master\.idea\
     文件          25  2017-01-24 14:14  spring-boot-sharding-jdbc-master\.idea\.name
     文件        1226  2017-01-24 14:14  spring-boot-sharding-jdbc-master\.idea\compiler.xml
     目录           0  2019-02-22 14:15  spring-boot-sharding-jdbc-master\.idea\copyright\
     文件          74  2017-01-24 14:14  spring-boot-sharding-jdbc-master\.idea\copyright\profiles_settings.xml
     目录           0  2019-02-22 14:15  spring-boot-sharding-jdbc-master\.idea\dictionaries\
     文件          83  2017-01-24 14:14  spring-boot-sharding-jdbc-master\.idea\dictionaries\tuyu.xml
     文件         172  2017-01-24 14:14  spring-boot-sharding-jdbc-master\.idea\encodings.xml
     目录           0  2019-02-22 16:33  spring-boot-sharding-jdbc-master\.idea\libraries\
     文件         436  2017-01-24 14:14  spring-boot-sharding-jdbc-master\.idea\libraries\Maven__cglib_cglib_3_1.xml
     文件         556  2017-01-24 14:14  spring-boot-sharding-jdbc-master\.idea\libraries\Maven__ch_qos_logback_logback_classic_1_1_8.xml
     文件         535  2017-01-24 14:14  spring-boot-sharding-jdbc-master\.idea\libraries\Maven__ch_qos_logback_logback_core_1_1_8.xml
     文件         513  2017-01-24 14:14  spring-boot-sharding-jdbc-master\.idea\libraries\Maven__commons_dbcp_commons_dbcp_1_4.xml
     文件         513  2017-01-24 14:14  spring-boot-sharding-jdbc-master\.idea\libraries\Maven__commons_pool_commons_pool_1_6.xml
     文件         481  2017-01-24 14:14  spring-boot-sharding-jdbc-master\.idea\libraries\Maven__com_alibaba_druid_1_0_12.xml
     文件         569  2017-01-24 14:14  spring-boot-sharding-jdbc-master\.idea\libraries\Maven__com_dangdang_sharding_jdbc_core_1_4_1.xml
     文件         660  2017-01-24 14:14  spring-boot-sharding-jdbc-master\.idea\libraries\Maven__com_dangdang_sharding_jdbc_self_id_generator_1_4_1.xml
     文件         522  2019-02-22 16:33  spring-boot-sharding-jdbc-master\.idea\libraries\Maven__com_fasterxml_classmate_1_3_3.xml
     文件         644  2019-02-22 16:33  spring-boot-sharding-jdbc-master\.idea\libraries\Maven__com_fasterxml_jackson_core_jackson_annotations_2_8_5.xml
     文件         595  2019-02-22 16:33  spring-boot-sharding-jdbc-master\.idea\libraries\Maven__com_fasterxml_jackson_core_jackson_core_2_8_5.xml
     文件         623  2019-02-22 16:33  spring-boot-sharding-jdbc-master\.idea\libraries\Maven__com_fasterxml_jackson_core_jackson_databind_2_8_5.xml
     文件         487  2017-01-24 14:14  spring-boot-sharding-jdbc-master\.idea\libraries\Maven__com_google_guava_guava_18_0.xml
     文件         534  2017-01-24 14:14  spring-boot-sharding-jdbc-master\.idea\libraries\Maven__com_jayway_jsonpath_json_path_2_2_0.xml
     文件         563  2017-01-24 14:14  spring-boot-sharding-jdbc-master\.idea\libraries\Maven__io_dropwizard_metrics_metrics_core_3_1_2.xml
     文件         554  2017-01-24 14:14  spring-boot-sharding-jdbc-master\.idea\libraries\Maven__javax_persistence_persistence_api_1_0.xml
     文件         611  2019-02-22 16:33  spring-boot-sharding-jdbc-master\.idea\libraries\Maven__javax_validation_validation_api_1_1_0_Final.xml
     文件         443  2017-01-24 14:14  spring-boot-sharding-jdbc-master\.idea\libraries\Maven__junit_junit_4_12.xml
     文件         562  2017-01-24 14:14  spring-boot-sharding-jdbc-master\.idea\libraries\Maven__mysql_mysql_connector_java_5_1_40.xml
     文件         530  2017-01-24 14:14  spring-boot-sharding-jdbc-master\.idea\libraries\Maven__net_minidev_accessors_smart_1_1.xml
     文件         509  2017-01-24 14:14  spring-boot-sharding-jdbc-master\.idea\libraries\Maven__net_minidev_json_smart_2_2_1.xml
............此处省略137个文件信息

评论

共有 条评论