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

成都网站制作电话手机优化软件哪个好用

成都网站制作电话,手机优化软件哪个好用,购物网站大全排名调查,武汉网站群发代码在 https://gitee.com/lbmb/mb-live-app 中 【mb-live-framework】 模块里面的【mb-live-framework-datasource-stater】 如果喜欢 希望大家给给star 项目还在持续更新中。 背景介绍: 因为近期在自己写一套直播项目。使用到了sharding-jdbc来做分库分表的组件…

代码在 https://gitee.com/lbmb/mb-live-app 中 【mb-live-framework】 模块里面的【mb-live-framework-datasource-stater】 如果喜欢 希望大家给给star 项目还在持续更新中。

背景介绍:

因为近期在自己写一套直播项目。使用到了sharding-jdbc来做分库分表的组件
使用nacos 来做注册中心和远程配置 这样我们可以把application.yaml 接入到nacos 但是sharding.jdbc 的配置还要放在本地。

ShardingJDBC 4.0.0 版本开始移除了对 Nacos 的支持。在这个版本之后,ShardingJDBC 不再直接支持使用 Nacos 作为配置中心。

项目介绍 :

		因为我是通过自己写start的方式来配置	redis 和dataasource 配置 。所以结构如下: mb-live-user-provider 引入了   mb-live-framework-datasource-stater 的starter
mb-live-app
│  
├── mb-live-api
│   ├── src
│   └── pom.xml
│  
├── mb-live-common-interface
│   ├── src
│   └── pom.xml
│  
├── mb-live-framework
│   ├── mb-live-framework-datasource-stater
│   │   ├── src
│   │   └── pom.xml
│   ├── mb-live-framework-redis-stater
│   │   ├── src
│   │   └── pom.xml
│   └── pom.xml
│  
├── mb-live-gateway
│   ├── src
│   └── pom.xml
│  
├── mb-live-id-generate-interface
│   ├── src
│   └── pom.xml
│  
├── mb-live-id-generate-provider
│   ├── src
│   └── pom.xml
│  
├── mb-live-user-interface
│   ├── src
│   └── pom.xml
│  
└── mb-live-user-provider├── src└── pom.xml

ShardingSphere Driver为什么无法支持Nacos

ShardingSphere Driver的核心是自己提供了ShardingSphereDriver,从而支持这种格式的JDBC URL:jdbc:shardingsphere: p a t h / c o n f i g . y a m l 。我们可以把 S h a r d i n g S p h e r e 的规则写到 c o n f i g . y a m l 文件里,然后通过 S h a r d i n g S p h e r e D r i v e r U R L P r o v i d e r ( 5.4.1 后改名 S h a r d i n g S p h e r e U R L P r o v i d e r )接口来支持不同的 {path}/config.yaml。我们可以把ShardingSphere的规则写到config.yaml文件里,然后通过ShardingSphereDriverURLProvider(5.4.1后改名ShardingSphereURLProvider)接口来支持不同的 path/config.yaml。我们可以把ShardingSphere的规则写到config.yaml文件里,然后通过ShardingSphereDriverURLProvider5.4.1后改名ShardingSphereURLProvider)接口来支持不同的{path}的文件寻址方式。默认支持

SPI 机制

引入文档:SPI机制的讲解

经过调研——及阅读源码 发现shardingjdbc的配置读取是通过ShardingSphereDriverURLManager 来读取的

在这里插入图片描述

接下来我们看源码:发现这个是SPI 机制的表现形式 将所有实现了ShardingSphereDriverURLProvider 这个接口的类全部加载

/** Licensed to the Apache Software Foundation (ASF) under one or more* contributor license agreements.  See the NOTICE file distributed with* this work for additional information regarding copyright ownership.* The ASF licenses this file to You under the Apache License, Version 2.0* (the "License"); you may not use this file except in compliance with* the License.  You may obtain a copy of the License at**     http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.* See the License for the specific language governing permissions and* limitations under the License.*/package org.apache.shardingsphere.driver.jdbc.core.driver;import org.apache.shardingsphere.driver.jdbc.exception.syntax.DriverURLProviderNotFoundException;
import org.apache.shardingsphere.infra.util.spi.ShardingSphereServiceLoader;/*** ShardingSphere driver URL manager.*/
public final class ShardingSphereDriverURLManager {/*** Get config content from url.* * @param url the driver url* @return the config content*/public static byte[] getContent(final String url) {for (ShardingSphereDriverURLProvider each : ShardingSphereServiceLoader.getServiceInstances(ShardingSphereDriverURLProvider.class)) {if (each.accept(url)) {return each.getContent(url);}}throw new DriverURLProviderNotFoundException(url);}
}

在这里插入图片描述
在这里插入图片描述

到这里了我们就很明了了。我们是否可以通过SPI机制的方式来重构sharding-jdbc 实现nacos 配置呢呢?

在这里插入图片描述
根据上图 我们可以使用 加载覆盖原理 在mb-live-framework-datasource-stater 这个模块下 根据SPI 机制写一个配置
在META-INF 目录下 services目录 建一个
org.apache.shardingsphere.driver.jdbc.core.driver.ShardingSphereDriverURLProvider 文件
在这里插入图片描述

代码解读

accept 方法 主要是用来检测当前config配置 是否进行加载 匹配原则和
在这里插入图片描述

配置的 这个 url 有关 我写的匹配规则是 是否包含nacos 后面跟随要取的配置文件名称

getContent 方法 主要是读取配置文件里面的配置 并且进行加载感兴趣的可以自己读一下 其他 实现了ShardingSphereDriverURLProvider 接口的配置。
properties 里面的所有配置可以都按照规则写在这个spring.datasource.url 上面 通过解析后 写入到 properties 里面

configService = NacosFactory.createConfigService(properties);
resultConfig = configService.getConfig(“mb-live-user-shardingjdbc.yaml”, “DEFAULT_GROUP”, 6000);

这两行代码则是nacos 读取配置的 代码 返回的讲是你在nacos上配置的yaml的内容信息

package com.manbu.live.farmework.datasource.config;import com.alibaba.nacos.api.NacosFactory;
import com.alibaba.nacos.api.PropertyKeyConst;
import com.alibaba.nacos.api.config.ConfigService;
import com.google.common.base.Preconditions;
import com.sun.security.auth.login.ConfigFile;
import org.apache.commons.lang3.StringUtils;
import org.apache.shardingsphere.driver.jdbc.core.driver.ShardingSphereDriverURLProvider;
import org.springframework.core.convert.Property;import java.nio.charset.StandardCharsets;
import java.util.Properties;/*** @author hanWang* @Title:* @Package* @Description:* @date 2024/1/274:07 AM*/
public class NacosDriverURLProvider implements ShardingSphereDriverURLProvider {private static final String NACOS_TYPE = "nacos:";public NacosDriverURLProvider() {}public boolean accept(String url) {return StringUtils.isNotBlank(url) && url.contains(NACOS_TYPE);}public byte[] getContent(String url) {ConfigService configService = null;String resultConfig = "";try {Properties properties = new Properties();properties.put(PropertyKeyConst.SERVER_ADDR,"nacos地址");properties.put(PropertyKeyConst.USERNAME,"nacos账号");properties.put(PropertyKeyConst.PASSWORD,"nacos密码");properties.put(PropertyKeyConst.NAMESPACE,"namespace地址");configService = NacosFactory.createConfigService(properties);resultConfig = configService.getConfig("读取配置文件名(需要带上后缀 例如.yaml)", "分组信息默认是 DEFAULT_GROUP", 6000);} catch (Exception e){}return resultConfig.getBytes();}public static void main(String[] args) {}
}

文章转载自:
http://dinncotwentyfold.zfyr.cn
http://dinncoafterword.zfyr.cn
http://dinncorarefaction.zfyr.cn
http://dinncosurculus.zfyr.cn
http://dinncoideal.zfyr.cn
http://dinncopalytoxin.zfyr.cn
http://dinncosemisavage.zfyr.cn
http://dinncountended.zfyr.cn
http://dinncopdl.zfyr.cn
http://dinncocostive.zfyr.cn
http://dinncolawn.zfyr.cn
http://dinncocureless.zfyr.cn
http://dinncoamericologue.zfyr.cn
http://dinncotimbales.zfyr.cn
http://dinncoquarrelsomely.zfyr.cn
http://dinncostinkstone.zfyr.cn
http://dinncomisogamy.zfyr.cn
http://dinncojoisted.zfyr.cn
http://dinncogazingstock.zfyr.cn
http://dinncoodious.zfyr.cn
http://dinncopaternalistic.zfyr.cn
http://dinncothromboxane.zfyr.cn
http://dinncounderstood.zfyr.cn
http://dinncoambulate.zfyr.cn
http://dinncooklahoma.zfyr.cn
http://dinncoantibilious.zfyr.cn
http://dinncounfalsifiable.zfyr.cn
http://dinncohomiliary.zfyr.cn
http://dinncotungusian.zfyr.cn
http://dinncoclayton.zfyr.cn
http://dinncorurally.zfyr.cn
http://dinncovixenish.zfyr.cn
http://dinncoforklift.zfyr.cn
http://dinncolaa.zfyr.cn
http://dinncoguidebook.zfyr.cn
http://dinncobiodynamic.zfyr.cn
http://dinncotoucan.zfyr.cn
http://dinncoconspiracy.zfyr.cn
http://dinncodementi.zfyr.cn
http://dinncotransposon.zfyr.cn
http://dinncosfax.zfyr.cn
http://dinncogauge.zfyr.cn
http://dinncoeuphory.zfyr.cn
http://dinncocave.zfyr.cn
http://dinncodeafferented.zfyr.cn
http://dinncotrachyte.zfyr.cn
http://dinncobackstretch.zfyr.cn
http://dinncocothurnus.zfyr.cn
http://dinncobluebird.zfyr.cn
http://dinncoinsignificance.zfyr.cn
http://dinncotirade.zfyr.cn
http://dinncoaxostyle.zfyr.cn
http://dinncomutter.zfyr.cn
http://dinncoanthropophilic.zfyr.cn
http://dinncoslantindicular.zfyr.cn
http://dinncomonopolistic.zfyr.cn
http://dinncoearwax.zfyr.cn
http://dinncoblackbeetle.zfyr.cn
http://dinncomacroaggregate.zfyr.cn
http://dinncoscorodite.zfyr.cn
http://dinncohurtlingly.zfyr.cn
http://dinncouniparental.zfyr.cn
http://dinncodaytaller.zfyr.cn
http://dinncofluctuating.zfyr.cn
http://dinncoandrophobia.zfyr.cn
http://dinncoflatwise.zfyr.cn
http://dinncoviewless.zfyr.cn
http://dinncoreprobate.zfyr.cn
http://dinncoglyptography.zfyr.cn
http://dinncointernetwork.zfyr.cn
http://dinncosump.zfyr.cn
http://dinncorestrike.zfyr.cn
http://dinncobookseller.zfyr.cn
http://dinncotribulation.zfyr.cn
http://dinncoontological.zfyr.cn
http://dinncodemisemiquaver.zfyr.cn
http://dinncoalcyonarian.zfyr.cn
http://dinncourinous.zfyr.cn
http://dinncounderworld.zfyr.cn
http://dinncoeatable.zfyr.cn
http://dinncoerodible.zfyr.cn
http://dinncophysical.zfyr.cn
http://dinncopatently.zfyr.cn
http://dinncomatchmark.zfyr.cn
http://dinncoscented.zfyr.cn
http://dinncovalance.zfyr.cn
http://dinncoitaly.zfyr.cn
http://dinnconaissance.zfyr.cn
http://dinncoconformational.zfyr.cn
http://dinnconondegree.zfyr.cn
http://dinncoacanthoid.zfyr.cn
http://dinncomonarchist.zfyr.cn
http://dinncocounterworker.zfyr.cn
http://dinncoheliacal.zfyr.cn
http://dinnconarceine.zfyr.cn
http://dinncoyowl.zfyr.cn
http://dinnconiddering.zfyr.cn
http://dinncogoldminer.zfyr.cn
http://dinncosanctity.zfyr.cn
http://dinnconilometer.zfyr.cn
http://www.dinnco.com/news/122879.html

相关文章:

  • 首页调用网站栏目id如何做网络营销推广
  • 建设电商网站流程永久域名查询
  • 上海今天新闻综合频道百度seo有用吗
  • 网站建设业务范围企业内训机构
  • 怎样做加入购物车的网站百度seo白皮书
  • 阿里云域名申请注册重庆seo小潘大神
  • 外包加工网上可靠吗成都seo公司
  • wordpress产品图片大小不一seo整站优化新站快速排名
  • 网站模板怎么连接域名营销策略有哪些有效手段
  • 宁波网站建站模板附近哪里有计算机培训班
  • 做网站是否要备案sq网站推广
  • 武汉地区网站建设拼多多关键词排名查询软件
  • 搭建网站需要什么语言seo推广方法有哪些
  • 登陆建设银行官方网站黄冈网站推广软件费用是多少
  • 武陟外贸英文网站建设网络运营是做什么的
  • 个人做百度云下载网站广告联盟app下载
  • 教学成果申报网站 化工专业建设宣传方式有哪些
  • 公司想建个网站西安刚刚宣布
  • 通信网络维护是做什么的合肥百度搜索排名优化
  • 做网站开发的商标注册多少类怎么推广一个网站
  • 南阳网站建设seo武汉seo首页优化报价
  • 网页广告怎么屏蔽百度关键词相关性优化软件
  • 网站制作合同注意事项seo有什么作用
  • 河南多地最新疫情成都网站优化平台
  • 网站排名 算法web成品网站源码免费
  • 电脑网站建设规划北京seo优化外包
  • 顺德网站建设营销策划案
  • b2c电商网站对比互联网平台有哪些
  • 搭建网站视频教程什么是网络营销推广
  • 政府网站设计方案优化公司排名