溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

集成SSJ框架的applicationContext.xml的基本配置方法

發(fā)布時(shí)間:2021-07-05 17:38:24 來源:億速云 閱讀:147 作者:chen 欄目:大數(shù)據(jù)

這篇文章主要介紹“集成SSJ框架的applicationContext.xml的基本配置方法”,在日常操作中,相信很多人在集成SSJ框架的applicationContext.xml的基本配置方法問題上存在疑惑,小編查閱了各式資料,整理出簡(jiǎn)單好用的操作方法,希望對(duì)大家解答”集成SSJ框架的applicationContext.xml的基本配置方法”的疑惑有所幫助!接下來,請(qǐng)跟著小編一起來學(xué)習(xí)吧!

<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"       xmlns:context="http://www.springframework.org/schema/context"       xmlns:aop="http://www.springframework.org/schema/aop"       xmlns:tx="http://www.springframework.org/schema/tx"       xmlns:jpa="http://www.springframework.org/schema/data/jpa"       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/aop http://www.springframework.org/schema/aop/spring-aop.xsd       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd       http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd"><!--引入相應(yīng)的properties文件-->    <context:property-placeholder location="classpath:jdbc.properties"/><!--掃描對(duì)應(yīng)的包(帶有各層的標(biāo)志的注解@Repository, @Service,@Controller,@Autowired,@PersistenceContext)-->    <context:component-scan base-package="com.zh.aisell.service"/><!--配置連接池-->    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"><!--連接池的四大要素-->        <property name="driverClassName" value="${jdbc.driverClassName}"/><property name="url" value="${jdbc.url}"/><property name="username" value="${jdbc.username}"/><property name="password" value="${jdbc.password}"/><!--maxActive: 最大連接數(shù)量 -->        <property name="maxActive" value="150" /><!--minIdle: 最小空閑連接 -->        <property name="minIdle" value="5" /><!--maxIdle: 最大空閑連接 -->        <property name="maxIdle" value="20" /><!--initialSize: 初始化連接 -->        <property name="initialSize" value="30" /><!-- 用來配置數(shù)據(jù)庫(kù)斷開后自動(dòng)連接的 -->        <!-- 連接被泄露時(shí)是否打印 -->        <property name="logAbandoned" value="true" /><!--removeAbandoned: 是否自動(dòng)回收超時(shí)連接 -->        <property name="removeAbandoned" value="true" /><!--removeAbandonedTimeout: 超時(shí)時(shí)間(以秒數(shù)為單位) -->        <property name="removeAbandonedTimeout" value="10" /><!--maxWait: 超時(shí)等待時(shí)間以毫秒為單位 1000等于60秒 -->        <property name="maxWait" value="1000" /><!-- 在空閑連接回收器線程運(yùn)行期間休眠的時(shí)間值,以毫秒為單位. -->        <property name="timeBetweenEvictionRunsMillis" value="10000" /><!-- 在每次空閑連接回收器線程(如果有)運(yùn)行時(shí)檢查的連接數(shù)量 -->        <property name="numTestsPerEvictionRun" value="10" /><!-- 1000 * 60 * 30 連接在池中保持空閑而不被空閑連接回收器線程 -->        <property name="minEvictableIdleTimeMillis" value="10000" /><property name="validationQuery" value="SELECT NOW() FROM DUAL" /> </bean><!--配置entityManagerFactory-->    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"><!--注入連接池-->        <property name="dataSource" ref="dataSource"/><!--掃描對(duì)應(yīng)的包(帶@Entity的類)-->        <property name="packagesToScan" value="com.zh.aisell"/><!--配置適配器-->        <property name="jpaVendorAdapter"><bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"><!--是否顯示sql-->                <property name="showSql" value="true"/><!--建表策略:true代表update-->                <property name="generateDdl" value="false"/><!--配置方言-->                <property name="databasePlatform" value="org.hibernate.dialect.MySQLDialect"/></bean></property></bean><!--配置事務(wù)管理器-->    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"><property name="entityManagerFactory" ref="entityManagerFactory"/></bean><!--支持事務(wù)(注解支持)-->    <tx:annotation-driven/><!-- Spring Data Jpa配置 -->    <!-- base-package:掃描的包 -->    <jpa:repositories base-package="com.zh.aisell.repository"                      entity-manager-factory-ref="entityManagerFactory"                      transaction-manager-ref="transactionManager"                      factory-class="com.zh.aisell.repository.BaseRepositoryFactoryBean"    /></beans>

到此,關(guān)于“集成SSJ框架的applicationContext.xml的基本配置方法”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識(shí),請(qǐng)繼續(xù)關(guān)注億速云網(wǎng)站,小編會(huì)繼續(xù)努力為大家?guī)砀鄬?shí)用的文章!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI