<?xml version="1.0" encoding="UTF-8" ?>
<beans>
    <bean id=...>
    <bean id=...>
</beans>
  • <context:component-scan base-package="....">:自动扫描以创建 bean 实例;

1. 数据库配置

  • <context:property-placeholder />

    <context:property-placeholder location="classpath:jdbc.properties"/>

    数据库配置文件(jdbc.properties)在类路径(classpath,src/main/resources/)下;

    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
          destroy-method="close"
          p:driverClassName="${jdbc.driverClassName}"
          p:url="${jdbc.url}"
          p:username="${jdbc.username}"
          p:password="${jdbc.password}"/>
posted on 2018-06-05 22:22  未雨愁眸  阅读(135)  评论(0编辑  收藏  举报