spring的数据源基本配置_MySQL

WBOY
풀어 주다: 2016-06-01 13:17:39
원래의
1591명이 탐색했습니다.

aplictaionContext-dataSource的配置:

 1 <?xml version="1.0" encoding="utf-8"?> 2 <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" 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-3.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd"> 7  8     <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">10         <property name="locations">11             <list>12                 <value>classpath:config.properties</value>13             </list>14         </property>15     </bean>16 17     <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">19         <property name="driverClassName">20             <value>${sqlDriver}</value>21         </property>22         <property name="url">23             <value>${sqlUrl}</value>24         </property>25         <property name="username">26             <value>${sqlUserName}</value>27         </property>28         <property name="password">29             <value>${sqlPassword}</value>30         </property>31         <property name="maxActive">32             <value>${sqlMaxActive}</value>33         </property>34         <property name="maxWait">35             <value>${sqlMaxWait}</value>36         </property>37         <property name="maxIdle">38             <value>${sqlMaxIdle}</value>39         </property>40     </bean>41 42 </beans>
로그인 후 복사
propertyConfigurer用来配置用到的config.properties文件的位置,方便在datasource配置中引用。<br>config配置文件的写法如下:<br>
로그인 후 복사
1 sqlDriver=com.mysql.jdbc.Driver2 sqlUrl=jdbc:mysql://127.0.0.1:3306/mydatabase?useUnicode=true&characterEncoding=utf83 sqlUserName=root4 sqlPassword=1235 sqlMaxActive=5006 sqlMaxWait=10007 sqlMaxIdle=50
로그인 후 복사

 

记录下来供以后配置时参考。
로그인 후 복사
관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!