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

网站开发人员没有按照设计开发服务专业的公司网站设计

网站开发人员没有按照设计开发,服务专业的公司网站设计,济宁做网站大约多少钱,wordpress 不收录设置文章目录 目录 文章目录 前言 一、依赖和目录结构 二、使用步骤 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);}} 总结 在Java中Scheduled注解是用于指定定时任务的执行规则的。它可以应用于方法或者类上面。 如果应用于方法上该方法将被视为一个定时任务并按照指定的时间规则进行调度执行。 如果应用于类上该类中所有带有Scheduled注解的方法都会被视为定时任务。 Scheduled注解的参数可以用来指定任务的执行规则包括以下几个方面 fixedDelay指定任务开始执行之后的延迟时间毫秒数任务执行完成后再经过指定的延迟时间再次执行。例如Scheduled(fixedDelay 5000)表示任务开始执行后等待5秒后再次执行。 fixedRate指定任务开始执行之后的间隔时间毫秒数任务执行完成后立即开始下一次执行。例如Scheduled(fixedRate 5000)表示任务开始执行后每隔5秒执行一次。 initialDelay指定任务首次执行的延迟时间毫秒数。例如Scheduled(initialDelay 5000)表示任务首次执行延迟5秒。 cron使用Cron表达式指定复杂的任务执行规则。Cron表达式由6个部分组成分别表示秒、分钟、小时、日期、月份和星期几。例如Scheduled(cron 0 0 12 * * ?)表示每天中午12点执行任务。 除了以上参数Scheduled注解还支持fixedDelayString、fixedRateString和zone等属性可以使用字符串形式的时间间隔和指定时区。 需要注意的是Scheduled注解需要与EnableScheduling注解一起使用以启用定时任务的功能。
http://www.w-s-a.com/news/631919/

相关文章:

  • 景区旅游网站平台建设公司企业网站源码
  • 免费高清网站推荐喂来苏州网络科技有限公司
  • php做的大型网站有哪些备案博客域名做视频网站会怎么样
  • 去哪网站备案吗昭通网站建设
  • flash企业网站源码建筑材料采购网站
  • 网站可以换虚拟主机吗部门做网站优点
  • 如何做分类网站信息营销莱芜网页定制
  • 班级网站建设感想中国做视频网站有哪些
  • 做刷票的网站wordpress图片链接插件
  • 给客户做网站图片侵权沈阳做网站的地方
  • 网站开发步骤规划蓝天云免费空间主机
  • 网站字体规范wordpress找不到页面内容编辑
  • 静态网站建设参考文献茂名营销型网站制作公司
  • 君山区建设局网站风铃微网站怎么做
  • 购物网站销售管理合肥网络推广平台
  • 网站建设规划书txt微盘注册帐号
  • 小说网站开发实训报告企业网盘收费标准
  • mvc网站开发医疗医院网站建设
  • 天津市建设厅官方网站wordpress设置404
  • 贵阳好的网站建设免费正能量网站下载ww
  • 免费学习的网站平台自建站seo如何做
  • 海南三亚做网站公众号版面设计创意
  • 学校网站建设目的与意义合肥网页定制
  • 网站查询地址网站建设与维护费用
  • 做网站哪些软件比较好合肥外贸网站建设公司
  • 建网站需要哪些条件专业网站设计报价
  • 定制网站开发技术化妆品的网站布局设计图片大全
  • 网站模糊设计发布产品的免费平台有哪些
  • 网站建站什么目录桂林网站建设内容
  • 光明新区城市建设局网站长沙营销型网站制作费用