applicationContext.xml 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xmlns:p="http://www.springframework.org/schema/p"
  5. xmlns:context="http://www.springframework.org/schema/context"
  6. xmlns:tx="http://www.springframework.org/schema/tx"
  7. xmlns:task="http://www.springframework.org/schema/task"
  8. xsi:schemaLocation="
  9. http://www.springframework.org/schema/beans
  10. http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  11. http://www.springframework.org/schema/tx
  12. http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
  13. http://www.springframework.org/schema/context
  14. http://www.springframework.org/schema/context/spring-context-3.0.xsd
  15. http://www.springframework.org/schema/task
  16. http://www.springframework.org/schema/task/spring-task.xsd">
  17. <!-- 引入jdbc配置文件 -->
  18. <context:property-placeholder location="classpath:jdbc.properties" />
  19. <!--创建jdbc数据源 -->
  20. <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
  21. destroy-method="close">
  22. <property name="driverClassName" value="${driver}" />
  23. <property name="url" value="${url}" />
  24. <property name="username" value="${username}" />
  25. <property name="password" value="${password}" />
  26. </bean>
  27. <!-- (事务管理)transaction manager, use JtaTransactionManager for global tx -->
  28. <bean id="transactionManager"
  29. class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  30. <property name="dataSource" ref="dataSource" />
  31. </bean>
  32. <!-- 创建SqlSessionFactory,同时指定数据源 -->
  33. <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
  34. <property name="dataSource" ref="dataSource" />
  35. </bean>
  36. <!-- 可通过注解控制事务 -->
  37. <tx:annotation-driven />
  38. <!-- Mapper接口所在包名,Spring会自动查找其下的Mapper -->
  39. <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
  40. <property name="basePackage" value="com.js.kbt.mapper" />
  41. </bean>
  42. <context:component-scan base-package="com.js.kbt.socket"/>
  43. <!-- <context:component-scan base-package="com.js.kbt.task"/> -->
  44. <!-- 定时任务启动 -->
  45. <task:annotation-driven />
  46. <!-- //进行定时任务的类,将其定义为一个bean -->
  47. <!-- <bean id="lightingTestingTask" class="com.js.kbt.task.LightingTestingTask"></bean>
  48. <task:scheduled-tasks>
  49. <task:scheduled ref="lightingTestingTask" method="doTask" fixed-rate="1200000" />
  50. </task:scheduled-tasks> -->
  51. <!-- <bean id="helloServer" class="com.js.kbt.socket.HelloServer" scope="singleton" init-method="startServer" destroy-method="shutdown"/>
  52. <bean id="userHandler" class="com.js.kbt.socket.UserHandler" scope="prototype"/> -->
  53. </beans>