applicationContext-dao.xml 2.0 KB

123456789101112131415161718192021222324252627282930313233
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
  4. xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
  5. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  6. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
  7. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd
  8. http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
  9. http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.2.xsd">
  10. <!-- 加载db.properties配置文件 -->
  11. <context:property-placeholder location="classpath:properties/*.properties" />
  12. <!-- 数据库连接池 -->
  13. <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"
  14. destroy-method="close">
  15. <property name="url" value="${jdbc.url}" />
  16. <property name="username" value="${jdbc.username}" />
  17. <property name="password" value="${jdbc.password}" />
  18. <property name="driverClassName" value="${jdbc.driver}" />
  19. <property name="maxActive" value="10" />
  20. <property name="minIdle" value="5" />
  21. </bean>
  22. <!-- 让Spring管理SqlSessionFactory(使用的是MyBatis和Spring整合包中的) -->
  23. <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
  24. <!-- 数据库连接池 -->
  25. <property name="dataSource" ref="dataSource" />
  26. <!-- 加载MyBatis的全局配置文件 -->
  27. <property name="configLocation" value="classpath:mybatis/SqlMapConfig.xml" />
  28. </bean>
  29. <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
  30. <property name="basePackage" value="com.itheima.mapper" />
  31. </bean>
  32. </beans>