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

做蔬菜配送有什么网站可下载了解网站轮播图怎么做

做蔬菜配送有什么网站可下载了解,网站轮播图怎么做,广东东莞人才市场,中英西班牙网站建设目录 1.多数据源 2.事务配置 项目搭建参考: 从零开始搭建SpringBoot项目_从0搭建springboot项目-CSDN博客 SpringBoot学习笔记(二) 整合redismybatisDubbo-CSDN博客 1.多数据源 添加依赖 dependenciesdependencygroupIdorg.springframework.bootmybatisDubbo-CSDN博客 1.多数据源 添加依赖 dependenciesdependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-test/artifactIdscopetest/scope/dependencydependencygroupIdorg.apache.commons/groupIdartifactIdcommons-lang3/artifactIdversion3.5/version/dependency!--MyBatis整合SpringBoot的起步依赖--dependencygroupIdorg.mybatis.spring.boot/groupIdartifactIdmybatis-spring-boot-starter/artifactIdversion2.2.2/version/dependency!--MySQL的驱动依赖--dependencygroupIdmysql/groupIdartifactIdmysql-connector-java/artifactIdversion5.1.31/version/dependencydependencygroupIdorg.projectlombok/groupIdartifactIdlombok/artifactIdversion1.16.10/version/dependency/dependencies 增加数据库配置 spring.datasource.primary.jdbc-urljdbc:mysql://xxxx/table01?useUnicodetrueautoReconnecttruezeroDateTimeBehaviorconvertToNull spring.datasource.primary.usernamexxxxx spring.datasource.primary.passwordxxxxx spring.datasource.primary.driver-class-namecom.mysql.jdbc.Driverspring.datasource.second.jdbc-urljdbc:mysql://xxxxx/table02?useUnicodetrueautoReconnecttruezeroDateTimeBehaviorconvertToNull spring.datasource.second.usernamexxxxx spring.datasource.second.passwordxxxxx spring.datasource.second.driver-class-namecom.mysql.jdbc.Driver 添加配置类 PrimaryDbConfig.java Configuration MapperScan(basePackages {com.ziroom.dao.primary}, sqlSessionFactoryRef primarySqlSessionFactory) public class PrimaryDbConfig {Primary // 这里要添加Primary,在匹配不到数据源时,primaryData会作为默认数据源Bean(name primaryData)ConfigurationProperties(prefix spring.datasource.primary)public DataSource financeData() {return DataSourceBuilder.create().build();}Bean(name primarySqlSessionFactory)Primarypublic SqlSessionFactory loanSqlSessionFactory(Qualifier(primaryData) DataSource dataSource) throws Exception {SqlSessionFactoryBean bean new SqlSessionFactoryBean();bean.setDataSource(dataSource);bean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources(classpath:mapper/*.xml));return bean.getObject();}Bean(name primarySqlSessionTemplate)Primarypublic SqlSessionTemplate loanSqlSessionTemplate(Qualifier(primarySqlSessionFactory) SqlSessionFactory sqlSessionFactory) {return new SqlSessionTemplate(sqlSessionFactory);} }// 事务配置Bean(name primaryTransactionManager)Primarypublic DataSourceTransactionManager masterDataSourceTransactionManager(Qualifier(primaryData) DataSource dataSource) {return new DataSourceTransactionManager(dataSource);}SecondDbConfig.java Configuration MapperScan(basePackages {com.ziroom.dao.second}, sqlSessionFactoryRef secondSqlSessionFactory) public class SecondDbConfig {Bean(name secondData)ConfigurationProperties(prefix spring.datasource.second)public DataSource financeData() {return DataSourceBuilder.create().build();}Bean(name secondSqlSessionFactory)public SqlSessionFactory loanSqlSessionFactory(Qualifier(secondData) DataSource dataSource) throws Exception {SqlSessionFactoryBean bean new SqlSessionFactoryBean();bean.setDataSource(dataSource);bean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources(classpath:mapper/*.xml));return bean.getObject();}Bean(name secondSqlSessionTemplate)public SqlSessionTemplate loanSqlSessionTemplate(Qualifier(secondSqlSessionFactory) SqlSessionFactory sqlSessionFactory) {return new SqlSessionTemplate(sqlSessionFactory);} }// 事务配置 Bean(name secondTransactionManager)public DataSourceTransactionManager masterDataSourceTransactionManager(Qualifier(secondData) DataSource dataSource) {return new DataSourceTransactionManager(dataSource);} 添加mapper相关 启动类屏蔽DataSourceAutoConfiguration.java 注意:类似于SpringBoot学习笔记(二) 整合redismybatisDubbo-CSDN博客 中单数据源的情况,配置文件中配置了spring.datasource.* ,且MapperScan(value com.xxxx.crm.demo.mapper)加到主类上,说明指定的dao关联了默认的spring.datasource.*, 这种情况则不能排除DataSourceAutoConfiguration.class 添加测试类 ResponseBodyRequestMapping(value /testPrimary)public String testPrimary(){Budget budget new Budget();ListBudget budgets budgetMapper.queryBudgetActualList(budget);log.info(Primary 数据源查询 size:{}, budgets.size());return success;}-- 输出:Primary 数据源查询 size:30ResponseBodyRequestMapping(value /testSecond)public String testSecond(){Invoice invoice new Invoice();ListInvoice invoices invoiceMapper.selectListByParams(invoice);log.info(Second 数据源查询 size:{}, invoices.size());return success;} -- 输出:Second 数据源查询 size:402.事务配置 PrimaryDbConfig.java中增加 Bean(name primaryTransactionManager)public DataSourceTransactionManager masterDataSourceTransactionManager(Qualifier(primaryData) DataSource dataSource) {return new DataSourceTransactionManager(dataSource);} SecondDbConfig.java中增加 Bean(name secondTransactionManager)public DataSourceTransactionManager masterDataSourceTransactionManager(Qualifier(secondData) DataSource dataSource) {return new DataSourceTransactionManager(dataSource);} 测试类 BudgetService.java Service public class BudgetService {Autowiredprivate BudgetMapper budgetMapper;Autowiredprivate InvoiceMapper invoiceMapper;Transactional(valueprimaryTransactionManager,rollbackFor RuntimeException.class)public void saveBudget(Budget budget) {budget.setBudgetYear(1);budget.setBudgetMonth(1);budget.setPartner(2);budgetMapper.insertSelective(budget);if(true){throw new RuntimeException(数据源1抛出异常);}}Transactional(valuesecondTransactionManager,rollbackFor RuntimeException.class)public void saveInvoice(Invoice invoice) {invoice.setPostingDate(new Date());invoice.setAdvancePayment(x);invoice.setInvoiceDate(new Date());invoice.setJournalDate(new Date());invoice.setAllocateRowNo(1);invoiceMapper.insertSelective(invoice);if(true){throw new RuntimeException(数据源2抛出异常);}} }启动类加:EnableTransactionManagement 代码详见https://github.com/lizhjian/SpringBootTest
http://www.hkea.cn/news/14494233/

相关文章:

  • 廊坊营销网站团队网站建设海之睿
  • 冀icp 网站建设电商网站建设目的
  • 网站seo优缺点公司网站建设与设计制作
  • 做网站专题页的字大小是多少辽宁企业网站建设公司
  • 陕西省建设执业资格注册中心网站wordpress 关闭顶部
  • 做双语网站种子网站开发多少钱
  • 给个免费的网站好人有好报传统外贸网站的seo运用
  • 重庆制作网站公司哪家好电子商务网站开发形式选择
  • 免费网站推荐软件惠州网站建设创业
  • 婚纱网站布局ppt怎么做企业网站开发文献综述
  • .net网站制作php网站开发零基础教程
  • 网站建设和维护要花多少钱青蛙网站建设
  • 做网站比较好的数字手机网站怎么导入微信
  • 怎么在百度自己创网站动漫网站的设计与实现
  • 如何在ftp给网站做百度自动推送中华建筑网
  • 中国数学外国人做视频网站怎么做网站
  • 简网 互联 专业wordpress主机网站域名如何优化
  • 网站开发语言有什么沧州网站建设沧州
  • 服务器 网站打开慢安庆市住房和城乡建设局网站
  • 龙岩网站制作多少钱淮安市广德育建设网站
  • 做名片哪个网站可以找专门做中式服装平台的网站
  • 建站工具 ip建设网站有哪些公司
  • 网站代码修改广州网站设计开发
  • 汕头市企业网站建设教程成都网站建设科
  • 网站系统建设需要什么条件域名查询网138
  • 校园网站建设材料wordpress产品编辑
  • 查看网站是否做百度推广网络棋牌推广平台有哪些
  • 哪些网站做的最有特色网站制作和如何推广
  • 杭州网站建设交易网站建设项目明细表
  • 宁德网站推广网站活动策划怎么做