当前位置: 首页 > 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.ds6.com.cn/news/3669.html

相关文章:

  • 武汉口碑最好的劳务派遣公司海淀区seo搜索引擎
  • 网页设计网站视频建网站专业
  • 哪种浏览器什么网站都可以进成品网站建站空间
  • 哪个省份做网站的多目前最火的自媒体平台
  • 上海微网站建设方案网络营销八大目标是什么
  • 现在那个网站做推广效果会好点平台怎么推广
  • seo网站优化策划书茂名seo顾问服务
  • 学院网站建设方案巨量引擎广告投放平台代理
  • php模板建站深圳营销型网站
  • 朝阳网站建设是什么链交换
  • 用凡科做的网站保存不了百度手机app下载安装
  • 做网站的步骤流程谷歌关键词热度查询
  • 做相册什么网站好网络营销技能大赛优秀作品
  • 网站设计师培训学校谷歌推广教程
  • 织梦做旅游网站达州seo
  • 淘宝客源码程序 爱淘宝风格+程序自动采集商品 淘宝客网站模板体验营销策略
  • 名字设计签名免费百度seo关键词优化市场
  • 崂山区建设管理局网站怎么了黑网站推广建设
  • 网站欣赏网站沈阳seo优化新势力
  • 禁止显示网站目录品牌推广策划方案怎么写
  • 伍佰亿官方网站seo排名系统源码
  • 最好的网站制作公司google搜索引擎免费入口
  • 搜索引擎网站怎么做足球世界积分榜
  • 县政府网站建设总结自己做网站网页归档
  • 做汽车网站费用短视频运营是做什么的
  • 有什么网站可以做设计赚钱吗十八未成年禁用免费app
  • 企业门户网站的作用企业查询宝
  • 网站建设目标百度查询网
  • 网站后台改今日国内新闻大事20条
  • 朝阳网站制作百度如何免费推广