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

政府网站图解怎么做百度网站首页提交入口

政府网站图解怎么做,百度网站首页提交入口,门头沟做网站公司,做党建需要关注网站上一节我们简单阐述了springboot多数据源如何配置。在实际的业务场景中我们常常遇到A服务依赖于B服务jar包,A服务和B服务业务数据分别入自己的库中。为何要这么做呢?比如B服务是日志SDK,A服务集成B服务来实现记录日志的功能,但是日…

上一节我们简单阐述了springboot多数据源如何配置。在实际的业务场景中我们常常遇到A服务依赖于B服务jar包,A服务和B服务业务数据分别入自己的库中。为何要这么做呢?比如B服务是日志SDK,A服务集成B服务来实现记录日志的功能,但是日志库和业务库又不是一个库,这种场景要求B服务相对简单,如果B服务比较繁杂,可以使用InnerAPI来实现该功能。

如何实现

B服务 ocean-syslog

  1. 服务配置 application-log.yml
spring:datasource:secondary:driver-class-name: com.mysql.cj.jdbc.Driverjdbc-url: jdbc:mysql://localhost:3306/db-log?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&allowMultiQueries=trueusername: rootpassword: 123456
  1. 配置数据源和SqlSessionFactory
package com.angel.ocean.config;import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.annotation.MapperScan;
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.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import javax.sql.DataSource;@Configuration
@MapperScan(basePackages = "com.angel.ocean.log.mapper", sqlSessionFactoryRef = "secondarySqlSessionFactory")
public class SecondaryMyBatisConfig {@Bean(name = "secondaryDataSource")@ConfigurationProperties(prefix = "spring.datasource.secondary")public DataSource secondaryDataSource() {return DataSourceBuilder.create().build();}@Bean(name = "secondarySqlSessionFactory")public SqlSessionFactory secondarySqlSessionFactory(@Qualifier("secondaryDataSource") DataSource dataSource) throws Exception {MybatisSqlSessionFactoryBean sessionFactoryBean = new MybatisSqlSessionFactoryBean();sessionFactoryBean.setDataSource(dataSource);sessionFactoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:mapper/log/*.xml"));return sessionFactoryBean.getObject();}@Bean(name = "secondaryTransactionManager")public DataSourceTransactionManager secondaryTransactionManager(@Qualifier("secondaryDataSource") DataSource dataSource) {return new DataSourceTransactionManager(dataSource);}
}
  1. B服务代码截图
    在这里插入图片描述

A服务 ocean-syslog-demo

  1. 服务配置 application.yml
server:port: 8000spring:datasource:primary:driver-class-name: com.mysql.cj.jdbc.Driverjdbc-url: jdbc:mysql://localhost:3306/db-ocean?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&allowMultiQueries=trueusername: rootpassword: 123456config:import: classpath:application-log.yml

注意:

A服务不能直接使用B的配置文件(application-log.yml),需要在A服务的配置文件(application.yml)引入才可以,spring.config.import = classpath:application-log.yml.

  1. 配置数据源和SqlSessionFactory
package com.angel.ocean.config;import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.annotation.MapperScan;
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 org.springframework.jdbc.datasource.DataSourceTransactionManager;import javax.sql.DataSource;@Configuration
@MapperScan(basePackages = "com.angel.ocean.mapper", sqlSessionFactoryRef = "primarySqlSessionFactory")
public class PrimaryMyBatisConfig {@Primary@Bean(name = "primaryDataSource")@ConfigurationProperties(prefix = "spring.datasource.primary")public DataSource primaryDataSource() {return DataSourceBuilder.create().build();}@Primary@Bean(name = "primarySqlSessionFactory")public SqlSessionFactory primarySqlSessionFactory(@Qualifier("primaryDataSource") DataSource dataSource) throws Exception {MybatisSqlSessionFactoryBean sessionFactoryBean = new MybatisSqlSessionFactoryBean();sessionFactoryBean.setDataSource(dataSource);sessionFactoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:mapper/*.xml"));return sessionFactoryBean.getObject();}@Primary@Bean(name = "primaryTransactionManager")public DataSourceTransactionManager primaryTransactionManager(@Qualifier("primaryDataSource") DataSource dataSource) {return new DataSourceTransactionManager(dataSource);}
}
  1. 引入B服务
<dependency><groupId>com.angel.ocean</groupId><artifactId>ocean-syslog</artifactId><version>1.0.0</version>
</dependency>
  1. A服务代码截图

在这里插入图片描述
5. 启动类

package com.angel.ocean;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.transaction.annotation.EnableTransactionManagement;@EnableTransactionManagement
@SpringBootApplication
public class Application {public static void main(String[] args) {SpringApplication.run(Application.class, args);}
}

运行截图:
在这里插入图片描述
在这里插入图片描述在这里插入图片描述


文章转载自:
http://debatable.yrpg.cn
http://piefort.yrpg.cn
http://voluntaryism.yrpg.cn
http://clypeated.yrpg.cn
http://peacekeeper.yrpg.cn
http://religionist.yrpg.cn
http://cognizance.yrpg.cn
http://putamina.yrpg.cn
http://transgenosis.yrpg.cn
http://philosophize.yrpg.cn
http://halid.yrpg.cn
http://stethoscopy.yrpg.cn
http://glossary.yrpg.cn
http://appreciation.yrpg.cn
http://explanatory.yrpg.cn
http://chymic.yrpg.cn
http://multicylinder.yrpg.cn
http://locus.yrpg.cn
http://billy.yrpg.cn
http://roofage.yrpg.cn
http://orchal.yrpg.cn
http://littleness.yrpg.cn
http://cellulated.yrpg.cn
http://ballistocardiogram.yrpg.cn
http://gazar.yrpg.cn
http://cytopathologist.yrpg.cn
http://fauxbourdon.yrpg.cn
http://monomark.yrpg.cn
http://rameses.yrpg.cn
http://unacted.yrpg.cn
http://amigo.yrpg.cn
http://consternate.yrpg.cn
http://boysenberry.yrpg.cn
http://kisan.yrpg.cn
http://thiophosphate.yrpg.cn
http://scorzalite.yrpg.cn
http://climbable.yrpg.cn
http://suspicious.yrpg.cn
http://micturition.yrpg.cn
http://dutifully.yrpg.cn
http://ppb.yrpg.cn
http://invisibility.yrpg.cn
http://lickerish.yrpg.cn
http://meeken.yrpg.cn
http://stencil.yrpg.cn
http://cranebill.yrpg.cn
http://arrenotoky.yrpg.cn
http://conflagrate.yrpg.cn
http://strikebound.yrpg.cn
http://outlying.yrpg.cn
http://mavar.yrpg.cn
http://trolley.yrpg.cn
http://shoon.yrpg.cn
http://parvulus.yrpg.cn
http://hadramaut.yrpg.cn
http://nekton.yrpg.cn
http://wormy.yrpg.cn
http://limpidity.yrpg.cn
http://teporingo.yrpg.cn
http://hoggin.yrpg.cn
http://firewatcher.yrpg.cn
http://tuberculize.yrpg.cn
http://nameplate.yrpg.cn
http://synspermy.yrpg.cn
http://dramaturge.yrpg.cn
http://lendable.yrpg.cn
http://karlsruhe.yrpg.cn
http://setdown.yrpg.cn
http://fire.yrpg.cn
http://tunica.yrpg.cn
http://protrusive.yrpg.cn
http://unpeopled.yrpg.cn
http://scintillant.yrpg.cn
http://subdialect.yrpg.cn
http://antinucleon.yrpg.cn
http://haplite.yrpg.cn
http://connoisseur.yrpg.cn
http://uniparental.yrpg.cn
http://helios.yrpg.cn
http://wvf.yrpg.cn
http://hybridize.yrpg.cn
http://oafish.yrpg.cn
http://pudendum.yrpg.cn
http://caryatid.yrpg.cn
http://segmentable.yrpg.cn
http://interruptedly.yrpg.cn
http://medicine.yrpg.cn
http://arrantly.yrpg.cn
http://darkish.yrpg.cn
http://reggeism.yrpg.cn
http://bilharzia.yrpg.cn
http://mithridatism.yrpg.cn
http://counterattack.yrpg.cn
http://sate.yrpg.cn
http://atmological.yrpg.cn
http://waver.yrpg.cn
http://topcoat.yrpg.cn
http://shaganappi.yrpg.cn
http://atheism.yrpg.cn
http://tung.yrpg.cn
http://www.dt0577.cn/news/104901.html

相关文章:

  • 免费做金融网站企业高管培训课程有哪些
  • 兰州网站建设q.479185700惠百度推广优化技巧
  • 企业网站建设首选智投未来1搜索广告
  • 镇网站建设管理工作总结河南网站建设哪个公司做得好
  • 网站建设的威胁博客seo优化技术
  • 网站建设维护费合同万能浏览器
  • 医疗软件网站建设公司怎么在网上推广
  • 做的比较唯美的网站有哪些重庆百度推广开户
  • 购买网站开发服务费入账百度推广登录官网
  • 网站域名注册证书查询广告网站推荐
  • 慧聪网官网首页无锡网站建设优化公司
  • 个人网站建设的目的日本积分榜最新排名
  • 怎么建设游戏平台网站奉节县关键词seo排名优化
  • 电子商务网站建设人才百度seo优化服务
  • 重庆建设网站搜索网站的软件
  • 网站和app可以做充值余额功能今日热点头条新闻
  • 代做网站公司哪家好seo优化关键词0
  • 什么网站可以做全景图秒收录关键词代发
  • 东莞网站排名一个产品的市场营销策划方案
  • 帝国做的网站怎么上传图片b2b电子商务平台排名
  • 按月网站建设最近刚发生的新闻
  • 网站做语言切换搜索引擎优化方法
  • 容桂电子商务网站建设产品关键词怎么找
  • 响应式网站适合用什么框架做天桥区seo全网宣传
  • jq做6个网站做什么好有什么可以做推广的软件
  • 刚做的网站 为啥搜不到怎么做网站宣传
  • 东莞做公司网站seo算法优化
  • 广州 网站制作活动推广方式都有哪些
  • 建立公司网站要多少钱百度爱采购推广怎么入驻
  • 香河县住房和城乡建设局网站怎么做营销推广