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

女人做一级a网站免费网站运营推广的方法有哪些

女人做一级a网站免费,网站运营推广的方法有哪些,网站建设网站排名优化金牌服务,做数码测评的网站前言 本博客姊妹篇 基于SpringBootDruid实现多数据源:原生注解式基于SpringBootDruid实现多数据源:注解编程式基于SpringBootDruid实现多数据源:baomidou多数据源 一、功能描述 配置方式:配置文件中实现多数据源,非…

前言

本博客姊妹篇

  • 基于SpringBoot+Druid实现多数据源:原生注解式
  • 基于SpringBoot+Druid实现多数据源:注解+编程式
  • 基于SpringBoot+Druid实现多数据源:baomidou多数据源

一、功能描述

  • 配置方式:配置文件中实现多数据源,非动态
  • 使用方式:使用注解切换数据源

二、代码实现

2.1 配置

# spring配置
spring:# 数据源配置datasource:type: com.alibaba.druid.pool.DruidDataSourcedruid:web-stat-filter:enabled: trueurl-pattern: /*exclusions: '*.js,*.css,*.gif,*.png,*.jpg,*.ico,/druid/*'stat-view-servlet:enabled: trueurl-pattern: /druid/*login-username: adminlogin-password: 123456filter:stat:enabled: truelog-slow-sql: trueslow-sql-millis: 1000merge-sql: truewall:enabled: trueconfig:multi-statement-allow: truemaster:driver-class-name: com.mysql.cj.jdbc.Driverurl: jdbc:mysql://127.0.0.1:3306/boot_business?useUnicode=true&characterEncoding=UTF8&serverTimezone=GMT%2B8&useSSL=falseusername: rootpassword: rootinitial-size: 10min-idle: 10max-active: 100max-wait: 60000time-between-eviction-runs-millis: 60000min-evictable-idle-time-millis: 300000validation-query: select 1test-while-idle: truetest-on-borrow: falsetest-on-return: falsepool-prepared-statements: truemax-pool-prepared-statement-per-connection-size: 20slave:enabled: truedriver-class-name: com.mysql.cj.jdbc.Driverurl: jdbc:mysql://127.0.0.1:3306/boot_codegen?useUnicode=true&characterEncoding=UTF8&serverTimezone=GMT%2B8&useSSL=falseusername: rootpassword: rootinitial-size: 10min-idle: 10max-active: 100max-wait: 60000time-between-eviction-runs-millis: 60000min-evictable-idle-time-millis: 300000validation-query: select 1test-while-idle: truetest-on-borrow: falsetest-on-return: falsepool-prepared-statements: truemax-pool-prepared-statement-per-connection-size: 20

2.2 配置类

package com.qiangesoft.datasource.core;import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;import java.util.HashMap;
import java.util.Map;/*** 多数据源配置** @author qiangesoft* @date 2024-03-14*/
@Slf4j
@Configuration
public class DataSourceConfiguration {@Bean@ConfigurationProperties("spring.datasource.druid.master")public DruidDataSource masterDataSource() {DruidDataSource masterDataSource = DruidDataSourceBuilder.create().build();masterDataSource.setName(DataSourceType.MASTER.getType());return masterDataSource;}@Bean@ConfigurationProperties("spring.datasource.druid.slave")@ConditionalOnProperty(prefix = "spring.datasource.druid.slave", name = "enabled", havingValue = "true")public DruidDataSource slaveDataSource() {DruidDataSource slaveDataSource = DruidDataSourceBuilder.create().build();slaveDataSource.setName(DataSourceType.SLAVE.getType());return slaveDataSource;}@Bean@Primarypublic DynamicDataSource dynamicDataSource(DruidDataSource masterDataSource, DruidDataSource slaveDataSource) {Map<Object, Object> targetDataSources = new HashMap<>();targetDataSources.put(masterDataSource.getName(), masterDataSource);targetDataSources.put(slaveDataSource.getName(), slaveDataSource);return new DynamicDataSource(masterDataSource, targetDataSources);}
}

2.3 多数据源扩展实现

package com.qiangesoft.datasource.core;import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;import javax.sql.DataSource;
import java.util.Map;/*** 动态数据源** @author qiangesoft* @date 2024-03-14*/
public class DynamicDataSource extends AbstractRoutingDataSource {public DynamicDataSource(DataSource defaultTargetDataSource, Map<Object, Object> targetDataSources) {super.setDefaultTargetDataSource(defaultTargetDataSource);super.setTargetDataSources(targetDataSources);super.afterPropertiesSet();}@Overrideprotected Object determineCurrentLookupKey() {return DataSourceContext.getDataSource();}
}

2.4 切面

package com.qiangesoft.datasource.core;import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;import java.util.Objects;/*** 多数据源处理** @author qiangesoft* @date 2024-03-14*/
@Slf4j
@Order(1)
@Aspect
@Component
public class DataSourceAspect {/*** 切点*/@Pointcut("@annotation(com.qiangesoft.datasource.core.DataSource)")public void pointCut() {}/*** 通知** @param joinPoint* @return* @throws Throwable*/@Around("pointCut()")public Object around(ProceedingJoinPoint joinPoint) throws Throwable {DataSource dataSource = this.getDataSource(joinPoint);if (dataSource == null) {DataSourceContext.setDataSource(DataSourceType.MASTER);} else {DataSourceContext.setDataSource(dataSource.value());}try {return joinPoint.proceed();} finally {DataSourceContext.removeDataSource();}}/*** 获取数据源** @param joinPoint* @return*/public DataSource getDataSource(ProceedingJoinPoint joinPoint) {MethodSignature signature = (MethodSignature) joinPoint.getSignature();// 方法上查找注解DataSource dataSource = AnnotationUtils.findAnnotation(signature.getMethod(), DataSource.class);if (Objects.nonNull(dataSource)) {return dataSource;}// 类上查找注解return AnnotationUtils.findAnnotation(signature.getDeclaringType(), DataSource.class);}
}

2.5 线程本地变量

package com.qiangesoft.datasource.core;/*** 数据源上下文** @author qiangesoft* @date 2024-03-14*/
public class DataSourceContext {/*** 线程本地变量:数据源*/private static final ThreadLocal<String> CONTEXT_HOLDER = new ThreadLocal<>();/*** 设置数据源的变量*/public static void setDataSource(DataSourceType dataSourceType) {CONTEXT_HOLDER.set(dataSourceType.getType());}/*** 获得数据源的变量*/public static String getDataSource() {return CONTEXT_HOLDER.get();}/*** 清空数据源变量*/public static void removeDataSource() {CONTEXT_HOLDER.remove();}
}

2.6 使用

package com.qiangesoft.datasource.controller;import com.qiangesoft.datasource.core.DataSource;
import com.qiangesoft.datasource.core.DataSourceType;
import com.qiangesoft.datasource.entity.SysUser;
import com.qiangesoft.datasource.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;import java.util.List;/*** <p>* 用户信息 前端控制器* </p>** @author qiangesoft* @since 2024-03-14*/
@RestController
@RequestMapping("/sys/user")
public class SysUserController {@Autowiredprivate ISysUserService sysUserService;@DataSource(DataSourceType.MASTER)@GetMapping("/master")public List<SysUser> listMaster() {return sysUserService.list();}@DataSource(DataSourceType.SLAVE)@GetMapping("/slave")public List<SysUser> listSlave() {return sysUserService.list();}}

文章转载自:
http://bundu.fzLk.cn
http://hairiness.fzLk.cn
http://surfy.fzLk.cn
http://atergo.fzLk.cn
http://gink.fzLk.cn
http://prostitute.fzLk.cn
http://isobutylene.fzLk.cn
http://baseband.fzLk.cn
http://breathe.fzLk.cn
http://exocoeiom.fzLk.cn
http://waybill.fzLk.cn
http://facp.fzLk.cn
http://choreic.fzLk.cn
http://unwarned.fzLk.cn
http://aviation.fzLk.cn
http://disequilibrium.fzLk.cn
http://eligibly.fzLk.cn
http://climbing.fzLk.cn
http://philabeg.fzLk.cn
http://ranch.fzLk.cn
http://neutrality.fzLk.cn
http://invaluably.fzLk.cn
http://tallyho.fzLk.cn
http://gustatorial.fzLk.cn
http://deserve.fzLk.cn
http://xylyl.fzLk.cn
http://overclaim.fzLk.cn
http://magnetostatic.fzLk.cn
http://tuffaceous.fzLk.cn
http://eightscore.fzLk.cn
http://semifascist.fzLk.cn
http://cladogram.fzLk.cn
http://scarehead.fzLk.cn
http://censurable.fzLk.cn
http://lowering.fzLk.cn
http://indubitable.fzLk.cn
http://thomasine.fzLk.cn
http://oneiric.fzLk.cn
http://embassador.fzLk.cn
http://graveward.fzLk.cn
http://willful.fzLk.cn
http://scylla.fzLk.cn
http://menage.fzLk.cn
http://actionless.fzLk.cn
http://neuropsychic.fzLk.cn
http://mariculture.fzLk.cn
http://lobbyism.fzLk.cn
http://villi.fzLk.cn
http://antiestrogen.fzLk.cn
http://tailcoat.fzLk.cn
http://hateless.fzLk.cn
http://lych.fzLk.cn
http://lljj.fzLk.cn
http://ratably.fzLk.cn
http://flexion.fzLk.cn
http://bilberry.fzLk.cn
http://rocksy.fzLk.cn
http://liquesce.fzLk.cn
http://diurnation.fzLk.cn
http://elision.fzLk.cn
http://arse.fzLk.cn
http://retirement.fzLk.cn
http://bejabbers.fzLk.cn
http://sewn.fzLk.cn
http://neostyle.fzLk.cn
http://ranking.fzLk.cn
http://semifabricator.fzLk.cn
http://defenseless.fzLk.cn
http://glycine.fzLk.cn
http://ncas.fzLk.cn
http://transmissibility.fzLk.cn
http://zaire.fzLk.cn
http://primage.fzLk.cn
http://rubicundity.fzLk.cn
http://pusan.fzLk.cn
http://eris.fzLk.cn
http://galahad.fzLk.cn
http://rhematic.fzLk.cn
http://epidendrum.fzLk.cn
http://loyalty.fzLk.cn
http://tautosyllabic.fzLk.cn
http://keratinization.fzLk.cn
http://angiogram.fzLk.cn
http://iodopsin.fzLk.cn
http://iffy.fzLk.cn
http://lowball.fzLk.cn
http://ixtle.fzLk.cn
http://dialectologist.fzLk.cn
http://smsa.fzLk.cn
http://anchorite.fzLk.cn
http://chromatoscope.fzLk.cn
http://uvulitis.fzLk.cn
http://saccharometer.fzLk.cn
http://epirot.fzLk.cn
http://smear.fzLk.cn
http://paulette.fzLk.cn
http://pentode.fzLk.cn
http://zhdanov.fzLk.cn
http://innovationist.fzLk.cn
http://sententiously.fzLk.cn
http://www.dt0577.cn/news/114250.html

相关文章:

  • 广东网站建设哪家好html网站模板免费
  • 网站制作设计收费标准网络营销ppt模板
  • 建设网站具备的知识网络促销的方法有哪些
  • 长沙网站建设开发网站整站优化推广方案
  • 阿里云1m宽带做网站卡吗武汉网络推广广告公司
  • 经营范围 网站建设百度开户
  • 楚雄企业网站建设公司推广普通话心得体会
  • 做明星粉丝网站随州网络推广
  • 浙江网站建设平台南宁整合推广公司
  • 上海网站设计厂家网络app推广是什么工作
  • php做的网站论文推广下载app赚钱
  • 广州网站建设公司排名怎么让客户主动找你
  • 结合七牛云 做视频网站网络营销软件条件
  • 四川省建十一公司官网站长工具seo综合查询访问
  • 南京做网站优化的企业排名互联网宣传推广
  • 日本哪个网站做外贸比较好怎么建立网站?
  • 中小企业怎么优化网站南京seo网站管理
  • 做网站到底要不要营业执照软件编程培训学校排名
  • iis5.1 新建网站广告投放是做什么的
  • 做网站栏目是什么意思长沙建设网站制作
  • 企业管理系统免费网站百度官网客服
  • 山东郓城网站建设网络营销以什么为中心
  • 做项目搭建网站 构建数据库宁波网站关键词优化公司
  • 微网站开发微网站建设网站seo运营培训机构
  • 免费做国际网站有哪些网址收录网站
  • wordpress语音问答广州灰色优化网络公司
  • 广州营销网站建设设计旺道网站排名优化
  • 中小企业有哪些安卓优化大师历史版本
  • 洛阳网站建设价格低上海牛巨微seo优化
  • 网站开发技术选型网络营销服务平台