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

学做美食的视频网站有哪些音乐播放网站开发pc端

学做美食的视频网站有哪些,音乐播放网站开发pc端,怎么查网站是在哪里备案的,怎么建设自己网站文章目录 目录 文章目录 前言 一、依赖和目录结构 二、使用步骤 2.1 两个数据源的不同引用配置 2.2 对应的mapper 2.3 定时任务处理 总结 前言 一、依赖和目录结构 dependenciesdependencygroupIdorg.springframework.boot/groupIdartifa… 文章目录 目录 文章目录 前言 一、依赖和目录结构 二、使用步骤 2.1 两个数据源的不同引用配置 2.2 对应的mapper 2.3 定时任务处理  总结 前言 一、依赖和目录结构 dependenciesdependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter/artifactIdversion2.3.12.RELEASE/version/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactIdversion2.3.12.RELEASE/version/dependencydependencygroupIdcom.baomidou/groupIdartifactIdmybatis-plus-boot-starter/artifactIdversion3.5.1/version/dependencydependencygroupIdmysql/groupIdartifactIdmysql-connector-java/artifactIdversion5.1.49/version/dependency/dependencies 配置文件 server:port: 8089spring:datasource:remote :driver-class-name: com.mysql.jdbc.Driverjdbc-url: jdbc:mysql://192.168.31.2/student?useUnicodetruecharacterEncodingUTF-8useSSLfalseserverTimezoneUTCusername: rootpassword: 111local :driver-class-name: com.mysql.jdbc.Driverjdbc-url: jdbc:mysql://192.168.31.1/student?useUnicodetruecharacterEncodingUTF-8useSSLfalseserverTimezoneUTCusername: rootpassword: 111mybatis-plus:configuration:log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #开启sql日志二、使用步骤 2.1 两个数据源的不同引用配置 package com.config;import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean; import org.apache.ibatis.session.SqlSessionFactory; import org.mybatis.spring.SqlSessionFactoryBean; import org.mybatis.spring.SqlSessionTemplate; import org.mybatis.spring.annotation.MapperScan; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.jdbc.DataSourceBuilder; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; import org.springframework.core.io.support.PathMatchingResourcePatternResolver;import javax.annotation.Resource; import javax.sql.DataSource;/**** date Created in 2023/12/2 19:51* description本地数据源* modified By* version:*/ Configuration MapperScan(basePackages com.local.Mapper, sqlSessionTemplateRef sqlSessionTemplate1) public class MybatisLocalConfig {BeanConfigurationProperties(prefix spring.datasource.local)public DataSource dataSource1() {return DataSourceBuilder.create().build();}Beanpublic SqlSessionFactory sqlSessionFactory1(Qualifier(dataSource1) DataSource dataSource) throws Exception {MybatisSqlSessionFactoryBean factoryBean new MybatisSqlSessionFactoryBean();factoryBean.setDataSource(dataSource);// 设置mapper.xml文件的位置factoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources(classpath*:localmapper/*.xml));return factoryBean.getObject();}Beanpublic SqlSessionTemplate sqlSessionTemplate1(Qualifier(sqlSessionFactory1) SqlSessionFactory sqlSessionFactory) {return new SqlSessionTemplate(sqlSessionFactory);}} Configuration MapperScan(basePackages com.remote.Mapper, sqlSessionTemplateRef sqlSessionTemplate2) public class MybatisRemoteConfig {BeanConfigurationProperties(prefix spring.datasource.remote)public DataSource dataSource2() {return DataSourceBuilder.create().build();}Beanpublic SqlSessionFactory sqlSessionFactory2(Qualifier(dataSource2) DataSource dataSource) throws Exception {MybatisSqlSessionFactoryBean factoryBean new MybatisSqlSessionFactoryBean();factoryBean.setDataSource(dataSource);// 设置mapper.xml文件的位置factoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources(classpath*:mapper2/*.xml));return factoryBean.getObject();}Beanpublic SqlSessionTemplate sqlSessionTemplate2(Qualifier(sqlSessionFactory2) SqlSessionFactory sqlSessionFactory) {return new SqlSessionTemplate(sqlSessionFactory);} } 2.2 对应的mapper public interface CourseOneMapper extends BaseMapperCourse { }public interface CourseTwoMapper extends BaseMapperCourse {/*** 批量插入* param list*/Insert(script INSERT INTO tbl_course (name, teacher) VALUES foreach collectionlist itemitem separator, (#{item.name}, #{item.teacher}) /foreach /script)void batchInsert(Param(list) ListCourse list); }TableName(tbl_course) public class Course {TableId(type IdType.AUTO)private Integer id;private String name;private String teacher;public Course() {}public Course(Integer id, String name, String teacher) {this.id id;this.name name;this.teacher teacher;}/*** 获取* return id*/public Integer getId() {return id;}/*** 设置* param id*/public void setId(Integer id) {this.id id;}/*** 获取* return name*/public String getName() {return name;}/*** 设置* param name*/public void setName(String name) {this.name name;}/*** 获取* return teacher*/public String getTeacher() {return teacher;}/*** 设置* param teacher*/public void setTeacher(String teacher) {this.teacher teacher;}Overridepublic String toString() {return Course{id id , name name , teacher teacher };} } 2.3 定时任务处理  EnableScheduling //开启定时 Component public class MySchedule {Resourceprivate CourseOneMapper courseOneMapper;Resourceprivate CourseTwoMapper courseTwoMapper;/*** 每隔10秒执行一次*/Scheduled(fixedDelay 1000000)public void test(){//查询到要同步的数据ListCourse coursesOne courseOneMapper.selectList(null);//批量插入courseTwoMapper.batchInsert(coursesOne);}} 总结
http://www.yutouwan.com/news/65077/

相关文章:

  • php 上传移动到网站根目录南京网站排名提升
  • 布朗新风 中企动力提供网站建设石家庄开发网站
  • 建设99网站东莞百度搜索排名优化
  • 怎么用网站做word文件网络工程学什么
  • 大学学部网站建设工作基于站点的推广
  • 知名的网站建设公司排名简历制作专业模板
  • 团购网站模板下载租赁模板建站 网站的名称归属
  • 网站推广排名优化多少钱dede购物网站
  • 制作简历模板网站安卓版网页制作软件
  • seo网站架构设计国外儿童社区网站模板
  • 义务 网站建设做外贸的网站平台有哪些
  • 网站搭建的费用虚拟机怎么做多个网站
  • 网站交互方式2022年适合小学生的新闻
  • 最新军事新闻报道深圳博惠seo
  • wordpress企业建站视频seo网站的优化方案
  • 口腔医院东莞网站建设自己有网站 做app
  • dns网站卫士 收录无锡营销型网站价格
  • 网站设计 原型图浙江省住房城乡建设厅网站
  • 做网站需要服务器么美团网站界面设计
  • 诗人做的网站院网站建设情况报告
  • 网站设计标准字体南昌集团网站建设公司
  • 无版权图片做网站绵阳做网站的有哪些
  • 宁波网站建设流程图网站建设实训报告册
  • 租用网站空间网站开发demo是什么
  • 信阳网站公司企业展厅设计要点
  • wordpress站内信wordpress控制列表页
  • 江阴营销网站建设网站建设报价选兴田德润
  • 给自己的公司做网站怎么做好北京网站制作公司有哪些
  • 外贸小家电网站推广网站运行速度优化
  • 做美术鉴赏网站的心得甘德县wap网站建设公司