欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

springboot下配置多數(shù)據(jù)源的方法-創(chuàng)新互聯(lián)

一、springboot 簡(jiǎn)介

網(wǎng)站設(shè)計(jì)制作過(guò)程拒絕使用模板建站;使用PHP+MYSQL原生開(kāi)發(fā)可交付網(wǎng)站源代碼;符合網(wǎng)站優(yōu)化排名的后臺(tái)管理系統(tǒng);網(wǎng)站制作、做網(wǎng)站收費(fèi)合理;免費(fèi)進(jìn)行網(wǎng)站備案等企業(yè)網(wǎng)站建設(shè)一條龍服務(wù).我們是一家持續(xù)穩(wěn)定運(yùn)營(yíng)了10多年的創(chuàng)新互聯(lián)建站網(wǎng)站建設(shè)公司。

SpringBoot使開(kāi)發(fā)獨(dú)立的,產(chǎn)品級(jí)別的基于Spring的應(yīng)用變得非常簡(jiǎn)單,你只需"just run"。 我們?yōu)镾pring平臺(tái)及第三方庫(kù)提 供開(kāi)箱即用的設(shè)置,這樣你就可以有條不紊地開(kāi)始。多數(shù)Spring Boot應(yīng)用需要很少的Spring配置。

你可以使用SpringBoot創(chuàng)建Java應(yīng)用,并使用 java -jar 啟動(dòng)它或采用傳統(tǒng)的war部署方式。我們也提供了一個(gè)運(yùn)行"spring 腳本"的命令行工具。

二、傳統(tǒng)的DataSource配置

Java的javax.sql.DataSource接口提供了一個(gè)標(biāo)準(zhǔn)的使用數(shù)據(jù)庫(kù)連接的方法。傳統(tǒng)做法是,一個(gè)DataSource使用一個(gè)URL連

同相應(yīng)的證書(shū)去初始化一個(gè)數(shù)據(jù)庫(kù)連接。

開(kāi)發(fā)中,一個(gè)項(xiàng)目中經(jīng)常會(huì)使用到不知一個(gè)數(shù)據(jù)源,本文主要講解如何在springboot下整合mybatis配置多數(shù)據(jù)源。主要對(duì)比下傳統(tǒng)的xml配置數(shù)據(jù)源和springboot下的數(shù)據(jù)源配置。

首先介紹下傳統(tǒng)的xml下如何配置多數(shù)據(jù)源

1、項(xiàng)目結(jié)構(gòu)

使用maven構(gòu)建的項(xiàng)目中,所有的數(shù)據(jù)源配置到DAO層,即圖中 subscribecore.dal module

2、dal的目錄結(jié)構(gòu)

1、數(shù)據(jù)庫(kù)對(duì)應(yīng)的java實(shí)體類(lèi)。

2、每個(gè)庫(kù)對(duì)應(yīng)的mapper文件。

3、每個(gè)mapper文件對(duì)應(yīng)的到的xml文件。

4、生產(chǎn)環(huán)境\測(cè)試環(huán)境對(duì)應(yīng)的數(shù)據(jù)源配置文件。

5、每個(gè)數(shù)據(jù)庫(kù)對(duì)應(yīng)的配置文件。

3、具體的配置文件介紹

以mysql庫(kù)為例,詳細(xì)展開(kāi)對(duì)mysql數(shù)據(jù)配置的介紹

1、java實(shí)體類(lèi)

使用的mysql庫(kù)中的一張表,通過(guò)mybatis自動(dòng)生成工具,生成了chartconfig類(lèi)和chartconfigExample類(lèi)。

2、msyql庫(kù)的mapper文件

3、mapper文件對(duì)應(yīng)的到的xml文件

4、mysql測(cè)試環(huán)境對(duì)應(yīng)的數(shù)據(jù)源配置文件

5、myssql數(shù)據(jù)庫(kù)對(duì)應(yīng)的配置文件

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:context="http://www.springframework.org/schema/context" 
    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:cache="http://www.springframework.org/schema/cache" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans   http://www.springframework.org/schema/beans/spring-beans.xsd 
            http://www.springframework.org/schema/context  http://www.springframework.org/schema/context/spring-context.xsd 
            http://www.springframework.org/schema/tx   http://www.springframework.org/schema/tx/spring-tx.xsd 
            http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd 
            http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd"> 
  <context:component-scan base-package="com.zto.subscribecore"></context:component-scan> 
 
 
 
  <!-- 數(shù)據(jù)源 --> 
  <bean id="mysqlDataSource" class="com.alibaba.druid.pool.DruidDataSource" 
     init-method="init" destroy-method="close"> 
    <!-- 驅(qū)動(dòng)名稱(chēng) --> 
    <property name="DriverClassName" value="${mysql.DriverClassName}"/> 
    <!-- JDBC連接串 --> 
    <property name="url" value="${mysql.url}"/> 
    <!-- 數(shù)據(jù)庫(kù)用戶名稱(chēng) --> 
    <property name="username" value="${mysql.username}"/> 
    <!-- 數(shù)據(jù)庫(kù)密碼 --> 
    <property name="password" value="${mysql.password}"/> 
    <!-- 連接池大使用連接數(shù)量 --> 
    <property name="maxActive" value="${mysql.maxActive}"/> 
    <!-- 初始化大小 --> 
    <property name="initialSize" value="${mysql.initialSize}"/> 
    <!-- 獲取連接大等待時(shí)間 --> 
    <property name="maxWait" value="${mysql.maxWait}"/> 
    <!-- 連接池最小空閑 --> 
    <property name="minIdle" value="${mysql.minIdle}"/> 
    <!-- 逐出連接的檢測(cè)時(shí)間間隔 --> 
    <property name="timeBetweenEvictionRunsMillis" value="${mysql.timeBetweenEvictionRunsMillis}"/> 
    <!-- 最小逐出時(shí)間 --> 
    <property name="minEvictableIdleTimeMillis" value="${mysql.minEvictableIdleTimeMillis}"/> 
    <!-- 測(cè)試有效用的SQL Query --> 
    <property name="validationQuery" value="${mysql.validationQuery}"/> 
    <!-- 連接空閑時(shí)測(cè)試是否有效 --> 
    <property name="testWhileIdle" value="${mysql.testWhileIdle}"/> 
    <!-- 獲取連接時(shí)測(cè)試是否有效 --> 
    <property name="testOnBorrow" value="${mysql.testOnBorrow}"/> 
    <!-- 歸還連接時(shí)是否測(cè)試有效 --> 
    <property name="testOnReturn" value="${mysql.testOnReturn}"/> 
  </bean> 
 
  <bean id="mysqlTransactionManager" 
     class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> 
    <property name="dataSource" ref="mysqlDataSource"/> 
  </bean> 
 
  <tx:annotation-driven transaction-manager="mysqlTransactionManager"/> 
 
  <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> 
    <property name="basePackage" value="com.zto.subscribecore.dal.mapper.mysql"/> 
    <property name="sqlSessionFactoryBeanName" value="mysqlSqlSessionFactory"/> 
  </bean> 
 
  <bean id="mysqlSqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> 
    <property name="dataSource" ref="mysqlDataSource"/> 
    <property name="mapperLocations" value="classpath*:com/zto/subscribecore/dal/mapper/mysql/*.xml"></property> 
    <property name="typeAliasesPackage" value="com.zto.subscribecore.dal.domain"/> 
  </bean> 
 
</beans> 

分享題目:springboot下配置多數(shù)據(jù)源的方法-創(chuàng)新互聯(lián)
瀏覽地址:http://aaarwkj.com/article48/isjep.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供響應(yīng)式網(wǎng)站、網(wǎng)站制作服務(wù)器托管、品牌網(wǎng)站設(shè)計(jì)、網(wǎng)頁(yè)設(shè)計(jì)公司、定制開(kāi)發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

商城網(wǎng)站建設(shè)
亚洲精品欧美综合第四区| 精品一区二区三区乱码中文| 亚洲一区二区视频免费看| 日韩性视频激情在线一区| 日韩三级在线观看av| 日本韩国欧美一区二区在线| 五月天亚洲激情综合av| 人妻系列少妇人妻偷人| 亚洲欧洲国产视频一区二区 | 一区二区三区毛片视频| 丰满人妻被黑人猛烈进入免费| 亚洲另类视频一区二区| 美女露脸口爆吞精视频| 日本女人体内射精视频| 国产精品一区二区毛卡片| 我的农村中年激情熟妇| 日本成人午夜福利在线观看| 日韩精品人妻一区二区免| 97在线视频观看视频在线| 东京一区二区三区四区黄片| 国产91美女黄色在线观看| 中文字幕人妻在线播放| 久久精品噜噜噜成人av农村| 亚洲亚洲精品av在线动| 欧美老熟妇子乱视频在线| 自拍日韩亚洲一区在线| 中文字幕一区二区三区不卡日日| 大香蕉一区二区亚洲欧美| 强乱人妻中文字幕日本| 中文字幕伦理一区二区三区| av毛片在线播放免费| 亚洲第六页亚洲第一页| 久久日韩一区二区三区| 欧美亚洲午夜精品久久久| 国产精品三级高清在线| 欧美黄片网站在线观看| 日本高清中文精品在线不卡| 日韩精品电影一区在线观看| 国产熟女精品自拍嫩草| 日本久久在线观看视频| 欧美性极品少妇精品网站|