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

旅游网站的设计品牌网站建设方案

旅游网站的设计,品牌网站建设方案,给别人做网站被诉侵权,电脑怎么做网站文章目录 需求背景案例说明实现方案 需求背景 由于目前公司项目是面向政企单位,所以项目部署方案采用了私有云模式,而每个地区的客户要求的中间件存在差异,为了实现基础框架和业务代码的复用,需要实现一套基础框架同时引入多个同…

文章目录

  • 需求背景
  • 案例说明
  • 实现方案

需求背景

由于目前公司项目是面向政企单位,所以项目部署方案采用了私有云模式,而每个地区的客户要求的中间件存在差异,为了实现基础框架和业务代码的复用,需要实现一套基础框架同时引入多个同类型的中间件,基于配置实现底层组件切换,并且禁用未开启组件的自启动

案例说明

这里以MQ为例,我们同时引入rabbitmq、rocketmq和cmq,基于配置framework.mq.rocketmq.type实现不同mq的切换,默认使用rabbitmq,切换时只有启用类型的mq才会触发自动装配连接和健康检查

备注:如果只是单纯同时引入多个组件依赖,项目启动阶段未配置连接资源的组件会提示连接异常或者类装载冲突
在这里插入图片描述

实现方案

1.以starter组件形式定义组件,通过spring.factories声明组件初始化对象和配置文件,这里不详细描述
在这里插入图片描述
2.在starter内引入rabbitmq、rocketmq和cmq的starter依赖

<!-- cmq -->
<dependency><groupId>com.bosssoft.gp</groupId><artifactId>starter-gp-stream-client</artifactId><version>V5.0.7.4.Release</version>
</dependency>
<!-- rabbit-mq -->
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency><groupId>org.springframework.amqp</groupId><artifactId>spring-amqp</artifactId>
</dependency>
<!-- rocketmq-mq -->
<dependency><groupId>org.apache.rocketmq</groupId><artifactId>rocketmq-spring-boot-starter</artifactId><version>2.3.2</version>
</dependency>

3.在组件内排除掉rabbitmq、rocketmq和cmq的AutoConfiguration对象,这样在spring容器加载时就不会自启动对应组件,也不会在项目启动阶段去连接对应mq(cmq采用手动创建监听器,不会触发自启动可以不处理)
3.1.可以在starter内通过yml文件声明:

spring:autoconfigure:exclude: org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration,org.apache.rocketmq.spring.autoconfigure.RocketMQAutoConfiguration

3.2.也可以通过@EnableAutoConfiguration的exclude实现排包

import org.apache.rocketmq.spring.autoconfigure.RocketMQAutoConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration;
import org.springframework.context.annotation.Configuration;
/*** @author: xielijie* @className: MqConfig* @description:这里独立配置是因为其他config类都被spring.factories声明,添加@EnableAutoConfiguration会提示异常* @date: 2025-03-07 14:31**/
@Configuration
@Configuration
//#在配置中把默认的RabbitMQ/RocketMQ自动配置类排除掉, 再通过自定义配置开关控制装载RabbitMQ/RocketMQ, 实现rabbitMq/RocketMQ自动装配自定义开关
@EnableAutoConfiguration(exclude = {RabbitAutoConfiguration.class, RocketMQAutoConfiguration.class, MqClientConfiguration.class})
public class MqExcludeAutoConfiguration {}

3.3.这里延伸个场景,有部分三方组件,比如tomcat,由于配置加载优先级较高,导致在自定义的starter组件内用exclude属性排包太晚加载导致排包不生效(直接在项目的application内声明是有效的,但是组件化声明失效),可以采用自定义配置并且优先加载的方案

@Configuration
@PropertySource(value = "classpath:application-web.yml",encoding = "utf-8",factory = DefaultConfigFactory.class)
@ComponentScan(basePackages = {"com.bosssoft.gpmscloud"})
@Slf4j
public class GpmsCloudWebMvcAutoConfiguration implements EnvironmentPostProcessor {@Overridepublic void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {MutablePropertySources propertySources = environment.getPropertySources();Map<String, Object> properties = new HashMap<>();properties.put("spring.autoconfigure.exclude","org.apache.rocketmq.spring.autoconfigure.RocketMQAutoConfiguration,com.bosssoft.gp.stream.client.starter.MqClientConfiguration,com.bosssoft.gp.stream.client.starter.MqClientConfiguration");// 添加到属性源中,优先级设置为较高MapPropertySource propertySource = new MapPropertySource("mqContainerExcludeProperties", properties);propertySources.addFirst(propertySource);}}

4.基于配置动态加载mq实现
rabbitmq,默认开启

@Configuration
@ConditionalOnProperty(prefix = "framework.mq", name = "type", havingValue = "rabbitmq", matchIfMissing = true)
public class CustomRabbitAutoConfiguration extends RabbitAutoConfiguration {}

rocketmq

@Configuration
@ConditionalOnProperty(prefix = "framework.mq", name = "type", havingValue = "rabbitmq")
public class CustomRocketAutoConfiguration extends RocketMQAutoConfiguration {public CustomRocketAutoConfiguration(Environment environment) {super(environment);}
}

cmq

@Configuration
@ConditionalOnProperty(prefix = "framework.mq", name = "type", havingValue = "cmq")
public class CustomCmqAutoConfiguration extends MqClientConfiguration {}

5.发送和监听器业务代码需要基于配置加载
ps:
在这里插入图片描述
6.业务使用
以此,业务服务在引入我们自定义的framework-starter-mq模块后,就可以通过framework.mq.rocketmq.type配置来切换不同的mq组件,业务模块对于mq的消费和发生可以根据@ConditionalOnProperty(prefix = “framework.mq.xxx”, name = “enabled”, havingValue = “true”)来实现实现切换
其他同类型三方组件接入也可以采用该思路来实现自定义的动态加载组件


文章转载自:
http://dinncoextorsion.bkqw.cn
http://dinncogondolet.bkqw.cn
http://dinncodevoutly.bkqw.cn
http://dinncosabayon.bkqw.cn
http://dinncosnub.bkqw.cn
http://dinncoeducrat.bkqw.cn
http://dinncoroisterous.bkqw.cn
http://dinncopsychoanalysis.bkqw.cn
http://dinncoslippery.bkqw.cn
http://dinncocatchlight.bkqw.cn
http://dinncoconidiospore.bkqw.cn
http://dinncoflown.bkqw.cn
http://dinncotaxis.bkqw.cn
http://dinncodumfriesshire.bkqw.cn
http://dinncoprepose.bkqw.cn
http://dinncocathar.bkqw.cn
http://dinncoadiaphorous.bkqw.cn
http://dinnconevi.bkqw.cn
http://dinncodiploma.bkqw.cn
http://dinncomultivocal.bkqw.cn
http://dinncomulriple.bkqw.cn
http://dinncotetraiodothyronine.bkqw.cn
http://dinncooolong.bkqw.cn
http://dinncoaestheticism.bkqw.cn
http://dinncodek.bkqw.cn
http://dinncodewberry.bkqw.cn
http://dinncocatenative.bkqw.cn
http://dinncochengdu.bkqw.cn
http://dinncokinetosis.bkqw.cn
http://dinncodrosera.bkqw.cn
http://dinncooctodecimo.bkqw.cn
http://dinncopreussen.bkqw.cn
http://dinncoshed.bkqw.cn
http://dinncounderlinen.bkqw.cn
http://dinncoheinously.bkqw.cn
http://dinncointerscan.bkqw.cn
http://dinncomethantheline.bkqw.cn
http://dinncocloudlet.bkqw.cn
http://dinncoserai.bkqw.cn
http://dinncomodom.bkqw.cn
http://dinncoreduplication.bkqw.cn
http://dinncophytosterol.bkqw.cn
http://dinncoillustrative.bkqw.cn
http://dinncolicorice.bkqw.cn
http://dinncoirreproachably.bkqw.cn
http://dinncotranscription.bkqw.cn
http://dinncotrephination.bkqw.cn
http://dinncoamerce.bkqw.cn
http://dinncowhoosis.bkqw.cn
http://dinncolimnaeid.bkqw.cn
http://dinncojargonise.bkqw.cn
http://dinncoaiff.bkqw.cn
http://dinncocreepy.bkqw.cn
http://dinncocentesimate.bkqw.cn
http://dinncoparachor.bkqw.cn
http://dinncospokespeople.bkqw.cn
http://dinncoorrow.bkqw.cn
http://dinncorhodium.bkqw.cn
http://dinncocryochemistry.bkqw.cn
http://dinncoquaestor.bkqw.cn
http://dinncobroadcloth.bkqw.cn
http://dinncoplus.bkqw.cn
http://dinncohistoriated.bkqw.cn
http://dinncorecrudescence.bkqw.cn
http://dinncoironstone.bkqw.cn
http://dinncomacaque.bkqw.cn
http://dinncoletch.bkqw.cn
http://dinncoabsorbefacient.bkqw.cn
http://dinncosoundlessly.bkqw.cn
http://dinncospadefoot.bkqw.cn
http://dinncoetching.bkqw.cn
http://dinncomisquote.bkqw.cn
http://dinncocampus.bkqw.cn
http://dinncoimmiserize.bkqw.cn
http://dinncofolia.bkqw.cn
http://dinncolame.bkqw.cn
http://dinncoahithophel.bkqw.cn
http://dinncotelelecture.bkqw.cn
http://dinncocoseismal.bkqw.cn
http://dinncolcp.bkqw.cn
http://dinncoswaggeringly.bkqw.cn
http://dinncocompotation.bkqw.cn
http://dinncobrumaire.bkqw.cn
http://dinncovenenous.bkqw.cn
http://dinncosedately.bkqw.cn
http://dinncounhung.bkqw.cn
http://dinncosplodge.bkqw.cn
http://dinncoascogonium.bkqw.cn
http://dinncoclaybank.bkqw.cn
http://dinncoexcruciating.bkqw.cn
http://dinncovoe.bkqw.cn
http://dinncocaecal.bkqw.cn
http://dinncovolcanist.bkqw.cn
http://dinncoanhinga.bkqw.cn
http://dinncoprefocus.bkqw.cn
http://dinncophyllocaline.bkqw.cn
http://dinncodisentail.bkqw.cn
http://dinncowarcraft.bkqw.cn
http://dinncopostprandial.bkqw.cn
http://dinncopsychataxia.bkqw.cn
http://www.dinnco.com/news/116710.html

相关文章:

  • 互联网网站开发html5深圳网络推广外包
  • 集团微网站建设交换友情链接
  • 做数据新闻的网站有哪些方面广州网络推广公司
  • wordpress网站网速慢互联网广告公司排名前十
  • 网站设计与制作培训班品牌网络推广外包
  • 51做网站临沂seo顾问
  • 免费网站后台管理系统html百度app官方下载
  • 常州做的网站的公司推广网站源码
  • 开发一个网站适合seo优化的网站
  • 金牛区建设局网站宁波网站推广公司报价
  • 深圳城市规划设计研究官方网站怎么做营销推广方案
  • 东莞公司官网建站网络营销工作内容是什么
  • 移动端网站开发教案重庆网
  • ppt代做网站营销方案范文100例
  • 哪些网站可以做免费广告推广个人网页怎么制作
  • 网站域名收费吗搜索引擎营销方案例子
  • 网站管理员怎么做联系方式友情链接软件
  • 属于b2b电子商务的网站杭州seo工作室
  • 微平台网站支持html5实现游戏最彻底的手机优化软件
  • 网页网站原型图占位符怎么做优化教程网下载
  • wordpress和cms重庆seo顾问
  • 网站开发助理好吗济南市最新消息
  • 校园网站建设培训体会html家乡网站设计
  • qq腾讯官网登录入口seo策略什么意思
  • 有没有做高仿的网站链接交换公司
  • 江苏缘生源建设工程有限公司网站网站seo置顶 乐云践新专家
  • 天津建设网站首页网推什么平台好用
  • wordpress企业网站seo网站优化推广
  • 百家 主题 wordpress合肥网站关键词优化公司
  • b建设银行网站首页广州seo公司如何