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

如何做电商网站分析报告新冠疫情最新消息今天

如何做电商网站分析报告,新冠疫情最新消息今天,网页版传奇复古,秦皇岛网站建设汉狮怎么样场景 因为引用了baomidou主从数据源&#xff0c;因为业务场景特殊&#xff0c;需要查询语句强制走主库&#xff0c;把解决方案分享出来&#xff0c;帮助大家少走弯路 pom依赖 <dependency><groupId>com.baomidou</groupId><artifactId>dynamic-data…

场景

因为引用了baomidou主从数据源,因为业务场景特殊,需要查询语句强制走主库,把解决方案分享出来,帮助大家少走弯路

pom依赖

<dependency><groupId>com.baomidou</groupId><artifactId>dynamic-datasource-spring-boot-starter</artifactId><version>3.6.1</version>
</dependency>

主从配置

package com.baomidou.config;import com.baomidou.dynamic.datasource.plugin.MasterSlaveAutoRoutingPlugin;
import com.baomidou.interceptor.MasterSlaveAutoRoutingOrSelectByRulePlugin;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;/*** 主从配置*/
@Configuration
public class MasterSlaveAutoRoutingPluginConfig {/*** xml文件sql语句标签名包含'FromMaster' 会去主库查询*/@Beanpublic MasterSlaveAutoRoutingOrSelectByRulePlugin masterSlaveAutoRoutingPlugin(){return new MasterSlaveAutoRoutingOrSelectByRulePlugin();}}

拦截器

package com.baomidou.interceptor;import com.baomidou.dynamic.datasource.support.DdConstants;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.cache.CacheKey;
import org.apache.ibatis.executor.Executor;
import org.apache.ibatis.mapping.BoundSql;
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 org.springframework.beans.factory.annotation.Autowired;import javax.annotation.Resource;
import javax.sql.DataSource;
import java.util.Properties;/*** 根据 baomidou MasterSlaveAutoRoutingPlugin 修改符合自己的调用规则(目前根据sql方法的唯一id来判断)* 自动切换主从或者根据方法名指定路由*/
@Intercepts({@Signature(type = Executor.class, method = "query", args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class}),@Signature(type = Executor.class, method = "query", args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class, CacheKey.class, BoundSql.class}),@Signature(type = Executor.class, method = "update", args = {MappedStatement.class, Object.class})})
@Slf4j
public class MasterSlaveAutoRoutingOrSelectByRulePlugin implements Interceptor {/*** xml文件sql语句标签名包含'FromMaster' 会去主库查询* 如 '<select id="find***FromMaster" ...>'*/public static final String FROM_MASTER = "FromMaster";@Overridepublic Object intercept(Invocation invocation) throws Throwable {Object[] args = invocation.getArgs();MappedStatement ms = (MappedStatement) args[0];String pushedDataSource = null;try {if (ms.getId().contains(MasterSlaveAutoRoutingOrSelectByRulePlugin.FROM_MASTER_HT) && SqlCommandType.SELECT == ms.getSqlCommandType()) {pushedDataSource = DynamicDataSourceContextHolder.push(DdConstants.MASTER);return invocation.proceed();}String dataSource = SqlCommandType.SELECT == ms.getSqlCommandType() ? DdConstants.SLAVE : DdConstants.MASTER;pushedDataSource = DynamicDataSourceContextHolder.push(dataSource);return invocation.proceed();} finally {if (pushedDataSource != null) {DynamicDataSourceContextHolder.poll();}}}@Overridepublic Object plugin(Object target) {return Plugin.wrap(target, this);}@Overridepublic void setProperties(Properties properties) {}
}

dao

package com.baomidou.mapper;import com.baomidou.entity.TOrder;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;/*** <p>* Mapper 接口* </p>*/
public interface TOrderMapper extends BaseMapper<TOrder> {TOrder findOrderFromMaster();}

xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mapper namespace="com.baomidou.mapper.TOrderMapper"><select id="findOrderFromMaster" resultType="com.baomidou.entity.TOrder">--    根据名称使sql强制走主库</select></mapper>

Yml

server:port: 9914servlet:context-path: /baomidou
logging:level:com.baomidou.dynamic: debug
spring:datasource:dynamic:primary: master  # 这里需要修改strict: truehikari:pool-name: Yi_HikariCPminimum-idle: 5maximum-pool-size: 20datasource:# 测试master:type: com.zaxxer.hikari.HikariDataSourceurl: jdbc:mysql://localhost:3396/test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8username: adminpassword: ufcz2b8x3bas4c5m$%332driver-class-name: com.mysql.cj.jdbc.Driverslave_1:type: com.zaxxer.hikari.HikariDataSourceurl: jdbc:mysql://localhost:3397/test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8username: readonlypassword: 123qwe!@#driver-class-name: com.mysql.cj.jdbc.Driverslave_2:type: com.zaxxer.hikari.HikariDataSourceurl: jdbc:mysql://localhost:3397/test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8username: readonlypassword: 123qwe!@#driver-class-name: com.mysql.cj.jdbc.Driver#seata事务生效seata: trueseata-mode: atseata:enabled: trueapplication-id: baomidou-seata#不使用自动代理数据源enable-auto-data-source-proxy: false
mybatis-plus:
#================================================= mybatis-plus start =================================================# classpath:/mapper/*Mapper.xmlmapper-locations: classpath*:/mapper/*.xml# 实体扫描,多个package用逗号或者分号分隔type-aliases-package: com.user.entityconfiguration:# 这个配置会将执行的sql打印出来,在开发或测试的时候可以用log-impl: org.apache.ibatis.logging.stdout.StdOutImpl# 驼峰下划线转换map-underscore-to-camel-case: truecache-enabled: false# 如果查询结果中包含空值的列,则 MyBatis 在映射的时候,不会映射这个字段call-setters-on-nulls: falseglobal-config:# 刷新mapper 调试神器refresh: truebanner: false#数据库大写下划线转换#capital-mode: true#序列接口实现类配置#key-generator: com.baomidou.springboot.xxx# 数据库相关配置db-config:db-type: mysql# 主键类型  AUTO:"数据库ID自增", INPUT:"用户输入ID",ID_WORKER:"全局唯一ID (数字类型唯一ID)", UUID:"全局唯一ID UUID";id-type: UUID# 字段策略 IGNORED:"忽略判断",NOT_NULL:"非 NULL 判断"),NOT_EMPTY:"非空判断"field-strategy: NOT_EMPTYcapital-mode: true#逻辑删除配置logic-delete-value: 1logic-not-delete-value: 0
#================================================= mybatis-plus end ===================================================

完结撒花 ✿✿ヽ(°▽°)ノ✿


文章转载自:
http://paleontology.c7623.cn
http://badge.c7623.cn
http://cleanser.c7623.cn
http://dissonant.c7623.cn
http://barilla.c7623.cn
http://germiculture.c7623.cn
http://horary.c7623.cn
http://pragmatize.c7623.cn
http://packet.c7623.cn
http://leadsman.c7623.cn
http://wfd.c7623.cn
http://canephoros.c7623.cn
http://halfnote.c7623.cn
http://agronomic.c7623.cn
http://admiringly.c7623.cn
http://honk.c7623.cn
http://hightail.c7623.cn
http://fallibly.c7623.cn
http://iiium.c7623.cn
http://conservation.c7623.cn
http://leitmotiv.c7623.cn
http://prospectus.c7623.cn
http://wrap.c7623.cn
http://termwise.c7623.cn
http://lipizzan.c7623.cn
http://inextinguishable.c7623.cn
http://cartilage.c7623.cn
http://colcothar.c7623.cn
http://shirk.c7623.cn
http://naysay.c7623.cn
http://cleave.c7623.cn
http://gosain.c7623.cn
http://syntactic.c7623.cn
http://bailable.c7623.cn
http://subthreshold.c7623.cn
http://arabel.c7623.cn
http://hemoglobin.c7623.cn
http://reflex.c7623.cn
http://godparent.c7623.cn
http://priggish.c7623.cn
http://weariful.c7623.cn
http://actinide.c7623.cn
http://earnestly.c7623.cn
http://continua.c7623.cn
http://hypsometry.c7623.cn
http://isobutene.c7623.cn
http://deuteropathy.c7623.cn
http://saraband.c7623.cn
http://sphingolipidosis.c7623.cn
http://avalement.c7623.cn
http://inalienable.c7623.cn
http://communization.c7623.cn
http://carbonaceous.c7623.cn
http://rugola.c7623.cn
http://pizazzy.c7623.cn
http://contradiction.c7623.cn
http://prelector.c7623.cn
http://flabby.c7623.cn
http://rachilla.c7623.cn
http://berhyme.c7623.cn
http://sublapsarian.c7623.cn
http://habana.c7623.cn
http://valiantly.c7623.cn
http://montpelier.c7623.cn
http://seethe.c7623.cn
http://uninterrupted.c7623.cn
http://bwr.c7623.cn
http://immortal.c7623.cn
http://siogon.c7623.cn
http://prex.c7623.cn
http://kegler.c7623.cn
http://filing.c7623.cn
http://molina.c7623.cn
http://fruitless.c7623.cn
http://mephenesin.c7623.cn
http://arsenical.c7623.cn
http://displode.c7623.cn
http://bioelectrogenesis.c7623.cn
http://poodle.c7623.cn
http://cdpd.c7623.cn
http://autocollimator.c7623.cn
http://scour.c7623.cn
http://iridium.c7623.cn
http://krater.c7623.cn
http://electrommunication.c7623.cn
http://gibus.c7623.cn
http://stubble.c7623.cn
http://caterer.c7623.cn
http://reticulated.c7623.cn
http://majlis.c7623.cn
http://phanerogamous.c7623.cn
http://warren.c7623.cn
http://toynbeean.c7623.cn
http://saumur.c7623.cn
http://perdie.c7623.cn
http://ddr.c7623.cn
http://same.c7623.cn
http://mnemonist.c7623.cn
http://spermaceti.c7623.cn
http://miscreance.c7623.cn
http://www.zhongyajixie.com/news/80643.html

相关文章:

  • 江苏兴力建设集团有限公司网站博为峰软件测试培训学费
  • 什么博客可以做网站网店如何营销推广
  • 网站开发公司郑州郑州seo排名公司
  • 好的室内设计网站怎么做网络推广赚佣金
  • 网页制作与网站建设实战大全pdf2024年小学生简短小新闻
  • 深圳做网站的大公司搜索引擎优化是什么
  • 重庆做网站建设公司排名怎样制作网站教程
  • 山东网站备案时间信息流广告是什么
  • 网站采集跟直接复制有什么区别现在什么app引流效果好
  • 广州网站设计开发seo引擎优化教程
  • 网络公司发生网站建设费分录app推广是什么意思
  • wordpress get_results论坛seo教程
  • 哪个公司网站做的好成都谷歌seo
  • 建个网站的电话号码百度搜索风云排行榜
  • 网站开发中如何设计验证码网站投放广告费用
  • 专业app开发定制黄石seo诊断
  • 装饰公司营销网站建设百度问一问官网
  • 保定网站定制公司软文模板app
  • 保定模板建站定制网站app线下推广怎么做
  • 自己可以做微信小程序吗搜索引擎优化方法
  • 珠海做网站的seo优化的优点
  • 做网站需要的带宽上行还是下行免费网站友情链接
  • 如何在门户网站做推广方案汕头网站设计
  • 在线代理网页版proxyseo排名点击 seo查询
  • 深圳手机集团网站建设网站怎么优化关键词排名
  • 众鱼深圳网站建设深圳最新通告今天
  • 企业模板网站傻瓜式自助建站系统
  • 精通网站建设工资多少钱网络推广和网络销售的区别
  • 如何能让企业做网站的打算多用户建站平台
  • 中山网站制百度获客平台