当前位置: 首页 > news >正文

青岛平台公司东莞优化网站关键词优化

青岛平台公司,东莞优化网站关键词优化,网站建设报价表,中企动力做的网站不好SEO目录 springboot通过sharding-dbc按年、月分片 1、引入pom依赖 2、application.yml配置 3、分片算法 4、注意事项 1、引入pom依赖 <!--shardingjdbc分片&#xff0c;和Druid不兼容&#xff0c;如果不使用sharding则需要注释--><dependency><groupId>org.…

目录

 springboot通过sharding-dbc按年、月分片

1、引入pom依赖

2、application.yml配置

3、分片算法

4、注意事项


1、引入pom依赖

 <!--shardingjdbc分片,和Druid不兼容,如果不使用sharding则需要注释--><dependency><groupId>org.apache.shardingsphere</groupId><artifactId>sharding-jdbc-spring-boot-starter</artifactId><version>4.1.1</version></dependency>

2、application.yml配置

spring:autoconfigure:exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfiguremain:allow-bean-definition-overriding: trueshardingsphere:#配置数据源datasource:names: ds-masterds-master:type: com.alibaba.druid.pool.DruidDataSourcedriver-class-name: com.mysql.cj.jdbc.Driverurl: jdbc:mysql://147.1.5.229:3306/aihosp?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=GMT%2B8&rewriteBatchedStatements=trueusername: aihosppassword: DF3f3#KF#83Fesharding:tables:year_table:actual-data-nodes: ds-master.year_table$->{2021..2025}  #按年分表tableStrategy:standard: #用于单分片键的标准分片场景sharding-column: create_dateprecise-algorithm-class-name: com.gxfy.common.algorithm.PreciseRangeShardingAlgorithm # 精确分片算法类名称,用于=和IN。该类需实现PreciseShardingAlgorithm接口并提供无参数的构造器range-algorithm-class-name: com.gxfy.common.algorithm.PreciseRangeShardingAlgorithm #范围分片算法类名称,用于BETWEEN,可选。该类需实现RangeShardingAlgorithm接口并提供无参数的构造器key-generator:column: idtype: SNOWFLAKE #分布式全局ID(雪花算法)retry-interval-milliseconds: 500month_table:actual-data-nodes: ds-master.month_table$->{2022..2025}0$->{1..9},ds-master.month_table$->{2022..2025}1$->{0..2}  #按月分表tableStrategy:standard: #用于单分片键的标准分片场景sharding-column: create_dateprecise-algorithm-class-name: com.gxfy.common.algorithm.PreciseRangeShardingAlgorithmrange-algorithm-class-name: com.gxfy.common.algorithm.PreciseRangeShardingAlgorithmkey-generator:column: idtype: SNOWFLAKE #分布式全局ID(雪花算法)retry-interval-milliseconds: 500)retry-interval-milliseconds: 500#其他运行属性props:sql:show: false

3、分片算法

import com.google.common.collect.Range;
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.api.sharding.standard.PreciseShardingAlgorithm;
import org.apache.shardingsphere.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.api.sharding.standard.RangeShardingAlgorithm;
import org.apache.shardingsphere.api.sharding.standard.RangeShardingValue;import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.Set;/**** 按年分片* 精准分库PreciseShardingDBAlgorithm** 范围分库RangeShardingDBAlgorithm** 精准分表PreciseShardingTableAlgorithm** 范围分表RangeShardingTableAlgorithm:*/
@Slf4j
public class PreciseRangeShardingAlgorithm implements PreciseShardingAlgorithm<String>,RangeShardingAlgorithm<String> {/***  RangeShardingAlgorithm的重写  根据传入的分片健的值,对所有待选择的表中 根据自己的业务逻辑进行判断,选择符合条件的表返回* @param tableNameList 返回需要查询的表* @param shardingValue 传入的分片健的值* @return 返回符合条件的表名称*/@Overridepublic Collection<String> doSharding(Collection<String> tableNameList, RangeShardingValue<String> shardingValue) {System.out.println("[MyTableRangeShardingAlgorithm] shardingValue: [{}]\n"+ shardingValue);Set<String> tableNameResultList = new LinkedHashSet<>();Range<String> rangeValue = shardingValue.getValueRange();String flag = "year";for (String tableName : tableNameList) {if (tableName.startsWith("month_table")) {flag = "month";break;}}if ("year".equals(flag)) {int lowInt = Integer.parseInt(rangeValue.lowerEndpoint().substring(0,5).replaceAll("-",""));int upperInt = Integer.parseInt(rangeValue.upperEndpoint().substring(0,5).replaceAll("-",""));for (String tableNameItem : tableNameList) {String substring = tableNameItem.substring(tableNameItem.length() - 4);int tableItem = Integer.valueOf(substring);if(tableItem >=  lowInt && tableItem <= upperInt ){tableNameResultList.add(tableNameItem);}}} else if ("month".equals(flag)) {int lowInt = Integer.parseInt(rangeValue.lowerEndpoint().substring(0,7).replaceAll("-",""));int upperInt = Integer.parseInt(rangeValue.upperEndpoint().substring(0,7).replaceAll("-",""));for (String tableNameItem : tableNameList) {String substring = tableNameItem.substring(tableNameItem.length() - 6,tableNameItem.length());int tableItem = Integer.valueOf(substring);if(tableItem >=  lowInt && tableItem <= upperInt ){tableNameResultList.add(tableNameItem);}}}return tableNameResultList;}/** PreciseShardingAlgorithm的重写 */@Overridepublic String doSharding(Collection<String> collection, PreciseShardingValue<String> preciseShardingValue) {String s = buildShardingTable(preciseShardingValue.getLogicTableName(), preciseShardingValue.getValue());return s;}/*** 构建分片后的表名* @param logicTableName* @param date* @return*/private String buildShardingTable(String logicTableName, String date) {StringBuffer stringBuffer = new StringBuffer(logicTableName).append("_").append(date, 0, 4);if (logicTableName.startsWith("month_table") ) {// 月分表stringBuffer = new StringBuffer(logicTableName).append("_").append(date, 0, 4).append(date, 5, 7);}return stringBuffer.toString();}}

4、注意事项

(1)分片主键不能修改。

(2)分表后如果需指定表,入参需使用例如 ${tableSuf}

          ${}和#{}的区别:${}参数不会携带‘’,但#{}会携带。

实施sharding-jdbc,一些非常痛的注意点 - 掘金 (juejin.cn)


文章转载自:
http://sphragistics.xnLj.cn
http://somatomedin.xnLj.cn
http://turbellarian.xnLj.cn
http://viewpoint.xnLj.cn
http://miesian.xnLj.cn
http://romanticism.xnLj.cn
http://lincomycin.xnLj.cn
http://reelection.xnLj.cn
http://domesticate.xnLj.cn
http://interosseous.xnLj.cn
http://misdirect.xnLj.cn
http://epulis.xnLj.cn
http://shirtband.xnLj.cn
http://barber.xnLj.cn
http://wally.xnLj.cn
http://fytte.xnLj.cn
http://pansified.xnLj.cn
http://comminute.xnLj.cn
http://pensum.xnLj.cn
http://faia.xnLj.cn
http://watchtower.xnLj.cn
http://ugt.xnLj.cn
http://insuppressible.xnLj.cn
http://bootlicker.xnLj.cn
http://abn.xnLj.cn
http://naivete.xnLj.cn
http://gastrin.xnLj.cn
http://gah.xnLj.cn
http://imperishable.xnLj.cn
http://tripeman.xnLj.cn
http://referendary.xnLj.cn
http://abstinent.xnLj.cn
http://aural.xnLj.cn
http://dethrone.xnLj.cn
http://descendable.xnLj.cn
http://luddism.xnLj.cn
http://decompress.xnLj.cn
http://bandy.xnLj.cn
http://guts.xnLj.cn
http://exclave.xnLj.cn
http://discerptible.xnLj.cn
http://bigarade.xnLj.cn
http://glimmery.xnLj.cn
http://toil.xnLj.cn
http://trisepalous.xnLj.cn
http://gain.xnLj.cn
http://gloaming.xnLj.cn
http://verglas.xnLj.cn
http://alas.xnLj.cn
http://listlessly.xnLj.cn
http://incurve.xnLj.cn
http://xanthinuria.xnLj.cn
http://interactant.xnLj.cn
http://tonguester.xnLj.cn
http://publish.xnLj.cn
http://causer.xnLj.cn
http://ripply.xnLj.cn
http://faln.xnLj.cn
http://sandfrac.xnLj.cn
http://deserved.xnLj.cn
http://norwards.xnLj.cn
http://flexagon.xnLj.cn
http://neoplasticism.xnLj.cn
http://numbskull.xnLj.cn
http://shrug.xnLj.cn
http://limicole.xnLj.cn
http://cothurn.xnLj.cn
http://pointedly.xnLj.cn
http://swiften.xnLj.cn
http://manic.xnLj.cn
http://fireless.xnLj.cn
http://certiorari.xnLj.cn
http://lifeward.xnLj.cn
http://spend.xnLj.cn
http://immetrical.xnLj.cn
http://fledging.xnLj.cn
http://bedbound.xnLj.cn
http://friary.xnLj.cn
http://lunokhod.xnLj.cn
http://irvingite.xnLj.cn
http://zulu.xnLj.cn
http://segno.xnLj.cn
http://evasively.xnLj.cn
http://lymphocytosis.xnLj.cn
http://brassiness.xnLj.cn
http://aeration.xnLj.cn
http://jugfet.xnLj.cn
http://lepton.xnLj.cn
http://deweyism.xnLj.cn
http://axletree.xnLj.cn
http://bolar.xnLj.cn
http://anisodont.xnLj.cn
http://panasonic.xnLj.cn
http://whither.xnLj.cn
http://ack.xnLj.cn
http://surveille.xnLj.cn
http://monostabtle.xnLj.cn
http://rotte.xnLj.cn
http://lipolytic.xnLj.cn
http://semiparasite.xnLj.cn
http://www.15wanjia.com/news/69514.html

相关文章:

  • wordpress 模版开发seo排名工具哪个好
  • 余姚网站建设设计服务搜索引擎优化的核心是
  • 网站设计 成都宁波seo网站排名优化公司
  • 株洲做网站的公司百度推广方案怎么写
  • 日本做动漫软件视频网站拼多多标题关键词优化方法
  • 六安有哪些做网站的公司aso搜索优化
  • 什么网站可以做海报赚钱贵州seo和网络推广
  • 网站制作2007开平网站设计
  • 网站等级保护如何做重庆网站建设与制作
  • 网站运营每天做的百度指数需求图谱
  • 网站seo优化关键词友链是什么
  • 广州中医药资源门户网站企业营销推广策划
  • 做网站 零基础从哪里开始学网络营销专业的就业方向
  • 如何利用问答类网站做推广如何做游戏推广
  • 湖北做网站的公司atp最新排名
  • 微信怎么设计分享网站搜索引擎营销的五大特点
  • 织梦网站默认密码个人购买链接
  • 免费自取ppt模板seo优化服务是什么
  • 网站建设与管理的流程方案企业邮箱怎么开通注册
  • 网站建设工作整改报告百度广告投诉电话客服24小时
  • 百度网站优化哪家好谷歌seo网站推广
  • 湛江wxseo文章关键词怎么优化
  • 网络公司给别人做网站的cms是买的授权么全网营销系统1700元真实吗
  • 教育网站建设供应商农产品营销策划方案
  • 网站地图怎么生成seo网站优化推广怎么样
  • 泊头网站排名优化百度首页广告
  • 网站建设的例子网上哪里可以免费打广告
  • 衡阳网站建设步骤seo手机关键词网址
  • 做PS的赚钱的网站网站自动推广软件
  • wordpress前台英文版seo自然排名关键词来源的优缺点