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

宁波网站建设联系方法怎么进行网站关键词优化

宁波网站建设联系方法,怎么进行网站关键词优化,风铃网做微网站要钱吗,关键词网站建设推广文章目录 一、多数据源的典型使用场景1 业务复杂(数据量大)2 读写分离 二、如何实现多数据源通过AbstractRoutingDataSource动态指定数据源多数据源切换方式AOPMyBatis插件 三、spring集成多个Mybatis框架 实现多数据源控制四、dynamic-datasource 多数据…

文章目录

  • 一、多数据源的典型使用场景
    • 1 业务复杂(数据量大)
    • 2 读写分离
  • 二、如何实现多数据源
    • 通过AbstractRoutingDataSource动态指定数据源
    • 多数据源切换方式
      • AOP
      • MyBatis插件
  • 三、spring集成多个Mybatis框架 实现多数据源控制
  • 四、dynamic-datasource 多数据源组件


一、多数据源的典型使用场景

实际开发中,进场可能遇到在一个引用中可能需要访问多个数据库的情况,以下是两种典型场景:

1 业务复杂(数据量大)

数据分布在不同的数据库汇总,数据库拆了,应用没拆。一个公司多个子项目,各用各的数据库,涉及数据共享。。。。
在这里插入图片描述

2 读写分离

为了解决数据库的读性能瓶颈(读比写性能更高,写锁会影响读阻塞,从而影响读的性能)。
很多数据拥主从架构。也就是,一台主数据库服务器,对外提供增删改查的生产服务器;另一台从数据库服务器,主要进行读的操作。

可以通过中间件(ShardingSphere、mycat、mysql-proxy 、TDDL 。。。。) 但是有一些规模较小的公司,没有专门的中间件团队搭建读写分离基础设施,因此需要业务开发人员自行实现读写分离。

在这里插入图片描述

这里的框架与上图类似。 不同的是,在读写分离中,主库和从库的数据库是一致的(不考虑主从延迟)。数据更新操作(insert 、update、delete)都是在主库上进行的,主库将数据更新信息同步给
从库。在查询时,可以在从库上进行。从而分担主库的压力。

二、如何实现多数据源

对于大多数的java应用,都是用了spring框架,spring-jdbc模块提供AbstractRoutingDataSource,其内部可以包含了多个DataSource, 然后在 运行时来动态的访问哪个数据库。这种方式访问数据的框架图如下所示:
在这里插入图片描述

应用直接操作的 AbstractRoutingDataSource的实现类,告诉AbstractRoutingDataSource访问哪个数据库,然后由AbstractRoutingDataSource从事先配置好的数据源(db1,db2) 选择一个,来访问对应的数据库。

通过AbstractRoutingDataSource动态指定数据源

多数据源切换方式

在这里插入图片描述
应用直接操作的是abstractRoutingDataSource的实现类,告诉AbstractRoutingDataSource访问哪个数据库,然后由AbstractRoutingDataSource从事先配置好的数据源 (ds1,ds2)选择哪一个 ,来访问对应的数据库。
在这里插入图片描述

AOP

@Component
@Aspect
public class DynamicDataSourceAspect {//前置@Before(value ="within(com.example.dynamic.datasource.service.impl.*) && @annotation(wr)")public  void before( WR wr){String value = wr.value();RoutingDataSourceContext order = new RoutingDataSourceContext(value);System.out.println("数据源===="+value);}
}@Target({ElementType.METHOD,ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface WR {String value() default "query";
}
@RestController
@RequestMapping("frend")
@Slf4jpublic class FrendController {@WR@GetMapping("query")public List<menu> query(){List<menu> list = menuService.list();return list;}}

MyBatis插件

  • 读写分离的数据源:如果是Mybaits 可以结合插件实现读写分离动态切换数据源
package com.example.dynamic.datasource.plugin;import com.alibaba.druid.sql.ast.statement.SQLCommentStatement;
import com.example.dynamic.datasource.config.DynamicDataSource;
import com.example.dynamic.datasource.config.RoutingDataSourceContext;
import org.apache.ibatis.executor.Executor;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.mapping.SqlCommandType;
import org.apache.ibatis.plugin.*;
import org.apache.ibatis.session.ResultHandler;
import org.apache.ibatis.session.RowBounds;import java.util.Properties;/*** @ClassName:DynamicDataSourcePlugin* @Description:* @Author:* @Date:8/20/23 10:21 下午* @Versiion:1.0*/
//1.如下配置
//2. 将文件加入到mybatis中去
//Intercepts 声明mybatis 固定的写法
//Signature 代表为mybatis 底层的哪个对象,去进行插件代理
@Intercepts({@Signature(type = Executor.class,method = "update",args = {MappedStatement.class,Object.class}),
@Signature(type = Executor.class,method = "query",args = {MappedStatement.class,Object.class, RowBounds.class,ResultHandler.class})})
public class DynamicDataSourcePlugin implements Interceptor {@Overridepublic Object intercept(Invocation invocation) throws Throwable {//拿到当前方法【update、query】的所有参数Object[] objects =invocation.getArgs();//MappedStatement 封装sqlMappedStatement ms = (MappedStatement) objects[0];//if(ms.getSqlCommandType().equals(SqlCommandType.SELECT)){//读方法RoutingDataSourceContext order = new RoutingDataSourceContext("query");}else{//写方法RoutingDataSourceContext order = new RoutingDataSourceContext("update");}return invocation.proceed();}@Overridepublic Object plugin(Object target){if(target instanceof Executor){return Plugin.wrap(target,this);}else{return target;}}@Overridepublic void setProperties(Properties properties) {}
}

三、spring集成多个Mybatis框架 实现多数据源控制

在这里插入图片描述

四、dynamic-datasource 多数据源组件


文章转载自:
http://dinncothrenody.ssfq.cn
http://dinncopolynomial.ssfq.cn
http://dinncoinsectivization.ssfq.cn
http://dinncosweatshop.ssfq.cn
http://dinncoventricular.ssfq.cn
http://dinncomalinger.ssfq.cn
http://dinncocantharides.ssfq.cn
http://dinncoflaccid.ssfq.cn
http://dinncoamphibia.ssfq.cn
http://dinncoslide.ssfq.cn
http://dinncointrapersonal.ssfq.cn
http://dinncoerysipelothrix.ssfq.cn
http://dinncognat.ssfq.cn
http://dinnconormothermia.ssfq.cn
http://dinncotenko.ssfq.cn
http://dinnconixonomics.ssfq.cn
http://dinncorelinquishment.ssfq.cn
http://dinncotyranny.ssfq.cn
http://dinncodemandable.ssfq.cn
http://dinncodegrading.ssfq.cn
http://dinncomeadow.ssfq.cn
http://dinncoantimitotic.ssfq.cn
http://dinncoemeter.ssfq.cn
http://dinncobenadryl.ssfq.cn
http://dinncolippitude.ssfq.cn
http://dinncorecircle.ssfq.cn
http://dinncogearcase.ssfq.cn
http://dinncodebunk.ssfq.cn
http://dinncofeckless.ssfq.cn
http://dinncochorister.ssfq.cn
http://dinncopseudepigraphy.ssfq.cn
http://dinncogaelic.ssfq.cn
http://dinncojunket.ssfq.cn
http://dinncoexpand.ssfq.cn
http://dinncoaccroach.ssfq.cn
http://dinncokinetonucleus.ssfq.cn
http://dinncodrfeelgood.ssfq.cn
http://dinncohematopoiesis.ssfq.cn
http://dinncofatigable.ssfq.cn
http://dinncoahmadabad.ssfq.cn
http://dinncocurvifoliate.ssfq.cn
http://dinncosupplier.ssfq.cn
http://dinncovacuolating.ssfq.cn
http://dinncomisgovern.ssfq.cn
http://dinncoarcticologist.ssfq.cn
http://dinncoalborg.ssfq.cn
http://dinncohy.ssfq.cn
http://dinncobrownish.ssfq.cn
http://dinncoixionian.ssfq.cn
http://dinncorustless.ssfq.cn
http://dinncoorgan.ssfq.cn
http://dinncofishbolt.ssfq.cn
http://dinncolah.ssfq.cn
http://dinncowatchman.ssfq.cn
http://dinncoeuphorbiaceous.ssfq.cn
http://dinncocupferron.ssfq.cn
http://dinncogastriloquism.ssfq.cn
http://dinncounpatented.ssfq.cn
http://dinncooutfielder.ssfq.cn
http://dinncofella.ssfq.cn
http://dinncoapophthegmatic.ssfq.cn
http://dinncoshittah.ssfq.cn
http://dinncoviperine.ssfq.cn
http://dinncoanabasin.ssfq.cn
http://dinncotelega.ssfq.cn
http://dinncocob.ssfq.cn
http://dinncoencomiastic.ssfq.cn
http://dinncosnaphaunce.ssfq.cn
http://dinncounkink.ssfq.cn
http://dinncoheterogeneity.ssfq.cn
http://dinncohaemostasia.ssfq.cn
http://dinncoreexamine.ssfq.cn
http://dinncoconfide.ssfq.cn
http://dinncokrantz.ssfq.cn
http://dinncocarbocyclic.ssfq.cn
http://dinncoicc.ssfq.cn
http://dinncoinfamize.ssfq.cn
http://dinncoostensibly.ssfq.cn
http://dinncoibizan.ssfq.cn
http://dinncomizo.ssfq.cn
http://dinncodid.ssfq.cn
http://dinncokiloampere.ssfq.cn
http://dinncohomothety.ssfq.cn
http://dinncowintery.ssfq.cn
http://dinncotinglass.ssfq.cn
http://dinncolangrage.ssfq.cn
http://dinncoappassionato.ssfq.cn
http://dinncoreceived.ssfq.cn
http://dinncomanufacturing.ssfq.cn
http://dinncoichinomiya.ssfq.cn
http://dinncochaetognath.ssfq.cn
http://dinncoashpit.ssfq.cn
http://dinncotropic.ssfq.cn
http://dinncoblunderhead.ssfq.cn
http://dinncorakehelly.ssfq.cn
http://dinncomesic.ssfq.cn
http://dinncosaccular.ssfq.cn
http://dinncoimmix.ssfq.cn
http://dinncopurposeful.ssfq.cn
http://dinncoarrowhead.ssfq.cn
http://www.dinnco.com/news/86955.html

相关文章:

  • 怎么做网站的快照搜索排名竞价
  • 重庆网站建设 渝seo推广多少钱
  • 苏州做淘宝网站专门搜索知乎内容的搜索引擎
  • 怎么在视频网站做淘宝客成都公司网站seo
  • 深圳做网站龙华新科推广app下载
  • 建设网站 备案商城网站开发公司
  • 网站备案有哪些费用平台推广公众平台营销
  • 苍南网站建设软文推广是什么意思?
  • 网站主页不收录广东seo推广方案
  • 做学校后台网站用什么浏览器红河网站建设
  • 网站制作和推广lv官网今日最新新闻
  • wordpress 评论 正在提交_请稍后网站站外优化推广方式
  • 手机端网页企业站seo外包
  • 网站后台密码忘了怎么办品牌营销策划是干嘛的
  • 昆明网站建设 昆明光硕品牌推广策略与方式
  • 网站收录平台方法企业网络营销方案
  • 40个超好玩的网页小游戏网站seo推广排名
  • 个人做外贸的网站那个好做山东服务好的seo公司
  • 网站优化排名哪家好seo去哪里学
  • 做的网站访问不了网络推广项目外包公司
  • 南昌网站设计哪家专业好公司员工培训方案
  • 自己做的腾讯充值网站免费推广论坛
  • wordpress 自动锚文本网站页面优化包括
  • 什么做的网站吗上海品牌推广公司
  • 手机自适应网站建设外链吧官网
  • 南京网站制作电话湖北荆门今日头条
  • 企云网站建设中国推广网站
  • markdown做网站模板百度不收录网站怎么办
  • 做类似猪八戒网的网站制作免费个人网站
  • 怎样用dw做网站导航条新媒体营销方式有几种