spring中数据源配置方式

来源:互联网 发布:有哪些经济数据库 编辑:程序博客网 时间:2024/05/22 03:35
<?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:p="http://www.springframework.org/schema/p"
    xmlns:util="http://www.springframework.org/schema/util"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.0.xsd">
    
    <context:component-scan base-package="org.itfuture.examples" />
    <!--
    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>classpath:config1.properties</value>
                <value>classpath:config2.properties</value>
            </list>
        </property>
    </bean>
    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>classpath:config*.properties</value>
            </list>
        </property>
    </bean>
     -->
     
    <!--
      <context:property-placeholder location="classpath:config1.properties,classpath:config2.properties" />
    -->
      <context:property-placeholder location="classpath:config*.properties" />
    
    <bean id="dataSource"
        class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"
        p:driverClassName="${driverClassName}" p:url="${url}"
        p:username="${username}" p:password="${password}" />

</beans>
原创粉丝点击