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

新手怎么做电商在哪个网站永久观看不收费的直播

新手怎么做电商在哪个网站,永久观看不收费的直播,欧派全屋定制联系电话,凡客诚品官方网站的代码概述 因为项目中采集工厂中的设备码点的数据量比较大,需要集成TDengine时序数据库,所以需要设置双数据源 操作步骤 导入依赖 <!-- 多数据源支持 --><dependency><groupId>com.baomidou</groupId><artifactId>dynamic-datasource-spring-boot-s…

概述

因为项目中采集工厂中的设备码点的数据量比较大,需要集成TDengine时序数据库,所以需要设置双数据源

操作步骤

导入依赖

		<!-- 多数据源支持 --><dependency><groupId>com.baomidou</groupId><artifactId>dynamic-datasource-spring-boot-starter</artifactId><version>3.3.6</version></dependency><!-- taos连接驱动 --><dependency><groupId>com.taosdata.jdbc</groupId><artifactId>taos-jdbcdriver</artifactId><version>3.2.11</version></dependency>

 nacos 配置文件数据源修改

spring:servlet:multipart:max-file-size: 100MBmax-request-size: 100MBenabled: true# mysql 配置datasource:dynamic:primary: mysql-servertype: com.alibaba.druid.pool.DruidDataSourcemysql-server:driver-class-name: com.mysql.cj.jdbc.Driverjdbc-url: jdbc:mysql://ip:port/db?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghaiusername: usernamepassword: passwordinitial-size: 10max-active: 100min-idle: 10max-wait: 60000pool-prepared-statements: truemax-pool-prepared-statement-per-connection-size: 20time-between-eviction-runs-millis: 60000min-evictable-idle-time-millis: 300000test-while-idle: truetest-on-borrow: falsetest-on-return: falsestat-view-servlet:enabled: trueurl-pattern: /druid/*filter:stat:log-slow-sql: trueslow-sql-millis: 1000merge-sql: falsewall:config:multi-statement-allow: true# TDengine 配置tdengine-server:driver-class-name: com.taosdata.jdbc.rs.RestfulDriverjdbc-url: jdbc:TAOS-RS://ip:port/db?timezone=UTC-8&charset=utf-8username: usernamepassword: passwordpool-name: Data_trans_HikariCPminimum-idle: 10 #最小空闲连接数量idle-timeout: 600000 #空闲连接存活最大时间,默认600000(10分钟)maximum-pool-size: 100 #连接池最大连接数,默认是10auto-commit: true  #此属性控制从池返回的连接的默认自动提交行为,默认值:truemax-lifetime: 1800000 #此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认1800000即30分钟connection-timeout: 30000 #数据库连接超时时间,默认30秒,即30000

新增自定义数据源配置类

MySQL

/*** MySQL 双数据源配置* @author pumpkin* @date 2024/5/16 14:08*/
@Configuration
@MapperScan(basePackages = {"com.xxx.xxx.xxx.dao", "com.xxx.xxx.xxx.dao"}, sqlSessionTemplateRef  = "mysqlSqlSessionTemplate")
public class MysqlServerConfig {private final MybatisPlusProperties properties;public MysqlServerConfig(MybatisPlusProperties properties) {this.properties = properties;}@Bean(name = "mysqlDataSource")@ConfigurationProperties(prefix = "spring.datasource.mysql-server")@Primarypublic DataSource mysqlDataSource() {return DataSourceBuilder.create().build();}@Bean(name = "mysqlSqlSessionFactory")@Primarypublic SqlSessionFactory mysqlSqlSessionFactory(@Qualifier("mysqlDataSource") DataSource dataSource) throws Exception {
//        SqlSessionFactoryBean bean = new SqlSessionFactoryBean();MybatisSqlSessionFactoryBean bean = new MybatisSqlSessionFactoryBean();bean.setDataSource(dataSource);// 指定多个XML映射文件位置PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
//        bean.setMapperLocations(resolver.getResources("classpath*:/mapper/*.xml"));Resource[] resources1 = resolver.getResources("classpath*:mapper/**/*.xml");Resource[] resources2 = resolver.getResources("classpath*:mapper/*.xml");// 将多个资源数组合并为一个Resource[] mapperLocations = new Resource[resources1.length + resources2.length];System.arraycopy(resources1, 0, mapperLocations, 0, resources1.length);System.arraycopy(resources2, 0, mapperLocations, resources1.length, resources2.length);// 设置合并后的资源数组bean.setMapperLocations(mapperLocations);//        MybatisConfiguration configuration = this.properties.getConfiguration();
//        if (configuration == null && !StringUtils.hasText(this.properties.getConfigLocation())) {
//            configuration = new MybatisConfiguration();
//        }MybatisConfiguration configuration = new MybatisConfiguration();configuration.setMapUnderscoreToCamelCase(true);configuration.setDefaultFetchSize(100);configuration.setDefaultStatementTimeout(30);bean.setConfiguration(configuration);return bean.getObject();}@Bean(name = "mysqlTransactionManager")@Primarypublic DataSourceTransactionManager mysqlTransactionManager(@Qualifier("mysqlDataSource") DataSource dataSource) {return new DataSourceTransactionManager(dataSource);}@Bean(name = "mysqlSqlSessionTemplate")@Primarypublic SqlSessionTemplate mysqlSqlSessionTemplate(@Qualifier("mysqlSqlSessionFactory") SqlSessionFactory sqlSessionFactory) throws Exception {return new SqlSessionTemplate(sqlSessionFactory);}
}

TDengine

/*** TDengine 双数据源配置* @author pumpkin* @date 2024/5/16 14:08*/
@Configuration
@MapperScan(basePackages = {"com.xxx.xxx.xxx.tdengine"}, sqlSessionTemplateRef  = "tdengineSqlSessionTemplate")
public class TDengineServerConfig {@Bean(name = "tdengineDataSource")@ConfigurationProperties(prefix = "spring.datasource.tdengine-server")public DataSource tdengineDataSource() {return DataSourceBuilder.create().build();}@Bean(name = "tdengineSqlSessionFactory")public SqlSessionFactory tdengineSqlSessionFactory(@Qualifier("tdengineDataSource") DataSource dataSource) throws Exception {SqlSessionFactoryBean bean = new SqlSessionFactoryBean();bean.setDataSource(dataSource);bean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:mapper/tdengine/*.xml"));return bean.getObject();}@Bean(name = "tdengineTransactionManager")public DataSourceTransactionManager tdengineTransactionManager(@Qualifier("tdengineDataSource") DataSource dataSource) {return new DataSourceTransactionManager(dataSource);}@Bean(name = "tdengineSqlSessionTemplate")public SqlSessionTemplate tdengineSqlSessionTemplate(@Qualifier("tdengineSqlSessionFactory") SqlSessionFactory sqlSessionFactory) throws Exception {return new SqlSessionTemplate(sqlSessionFactory);}}

将访问对应数据源的 Mapper 类放在对应的包下,使用 DAO 或者 Mapper 层的方法的时候就会操作对应的数据源了

http://www.hengruixuexiao.com/news/46542.html

相关文章:

  • 网站建设公司创业计划书百度公司电话热线电话
  • 竖排导航网站爱站网为什么不能用了
  • 自助建站广告发布百度seo视频教程
  • 游戏网站的监管由谁来做优化推广什么意思
  • 做本地分类信息网站赚钱吗百度怎么投放自己的广告
  • 戚墅堰常州做网站百度账号中心
  • 临沂做网站好的公司sem是什么电镜
  • 物流公司网站建设方案百度搜索风云榜下载
  • 网站网站地图怎么做百度网页入口
  • php手机网站后台源码广州网站建设技术外包
  • 网站建设公司测评疫情最新数据消息
  • 网站建设服务合同是否缴纳印花税培训网站设计
  • 虐做视频网站重庆疫情最新消息
  • 网站源代码查看html网页制作步骤
  • 桂林哪里可以做网站windows优化工具
  • 编程scratch网站西安网站制作费用
  • 国内 设计网站的公司网站深圳网络推广专员
  • 广州网站建设第一公司如何找推广平台
  • 做网站如何上传apk推广一个产品有哪些方式
  • 设计服务网站牛奶推广软文文章
  • b2b商务平台排名seo软件
  • 北京企业展示网站建设不要手贱搜这15个关键词
  • 做视频网站弹窗百度打广告怎么收费
  • 百度上开个网站怎么做网络推广的好处
  • 可靠的微商城网站建设深圳货拉拉
  • 打开网站代码怎么写提高工作效率图片
  • 行业门户网站的优化怎么做yps行业门户系统信息流广告公司排名
  • 河北省住房城乡建设局网站首页培训机构在哪个平台找
  • 中牟郑州网站建设咸阳网站建设公司
  • 做网站好还是小程序好网站标题seo外包优化