|
@@ -1,54 +1,58 @@
|
|
|
-<?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:context="http://www.springframework.org/schema/context"
|
|
|
- xmlns:tx="http://www.springframework.org/schema/tx"
|
|
|
- xmlns:task="http://www.springframework.org/schema/task"
|
|
|
- xsi:schemaLocation="
|
|
|
- http://www.springframework.org/schema/beans
|
|
|
- http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
|
|
- http://www.springframework.org/schema/tx
|
|
|
- http://www.springframework.org/schema/tx/spring-tx-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/task
|
|
|
- http://www.springframework.org/schema/task/spring-task.xsd">
|
|
|
-
|
|
|
- <!-- 引入jdbc配置文件 -->
|
|
|
- <context:property-placeholder location="classpath:jdbc.properties" />
|
|
|
-
|
|
|
- <!--创建jdbc数据源 -->
|
|
|
- <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
|
|
|
- destroy-method="close">
|
|
|
- <property name="driverClassName" value="${driver}" />
|
|
|
- <property name="url" value="${url}" />
|
|
|
- <property name="username" value="${username}" />
|
|
|
- <property name="password" value="${password}" />
|
|
|
- </bean>
|
|
|
-
|
|
|
- <!-- (事务管理)transaction manager, use JtaTransactionManager for global tx -->
|
|
|
- <bean id="transactionManager"
|
|
|
- class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
|
|
|
- <property name="dataSource" ref="dataSource" />
|
|
|
- </bean>
|
|
|
-
|
|
|
- <!-- 创建SqlSessionFactory,同时指定数据源 -->
|
|
|
- <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
|
|
|
- <property name="dataSource" ref="dataSource" />
|
|
|
- </bean>
|
|
|
- <!-- 可通过注解控制事务 -->
|
|
|
- <tx:annotation-driven />
|
|
|
-
|
|
|
- <!-- Mapper接口所在包名,Spring会自动查找其下的Mapper -->
|
|
|
- <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
|
|
|
- <property name="basePackage" value="com.js.kbt.mapper" />
|
|
|
- </bean>
|
|
|
- <context:component-scan
|
|
|
- base-package="com.js.kbt.task" />
|
|
|
- <context:component-scan base-package="com.js.kbt.socket"/>
|
|
|
-
|
|
|
- <bean id="helloServer" class="com.js.kbt.socket.HelloServer" scope="singleton" init-method="startServer" destroy-method="shutdown"/>
|
|
|
-<!-- <bean id="nioServer" class="com.js.kbt.socket.NIOServer" scope="singleton" init-method="startServer" destroy-method="shutdown"/> -->
|
|
|
- <bean id="userHandler" class="com.js.kbt.socket.UserHandler" scope="prototype"/>
|
|
|
-</beans>
|
|
|
+<?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:context="http://www.springframework.org/schema/context"
|
|
|
+ xmlns:tx="http://www.springframework.org/schema/tx"
|
|
|
+ xmlns:task="http://www.springframework.org/schema/task"
|
|
|
+ xsi:schemaLocation="
|
|
|
+ http://www.springframework.org/schema/beans
|
|
|
+ http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
|
|
+ http://www.springframework.org/schema/tx
|
|
|
+ http://www.springframework.org/schema/tx/spring-tx-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/task
|
|
|
+ http://www.springframework.org/schema/task/spring-task.xsd">
|
|
|
+
|
|
|
+ <!-- 引入jdbc配置文件 -->
|
|
|
+ <context:property-placeholder location="classpath:jdbc.properties" />
|
|
|
+
|
|
|
+ <!--创建jdbc数据源 -->
|
|
|
+ <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
|
|
|
+ destroy-method="close">
|
|
|
+ <property name="driverClassName" value="${driver}" />
|
|
|
+ <property name="url" value="${url}" />
|
|
|
+ <property name="username" value="${username}" />
|
|
|
+ <property name="password" value="${password}" />
|
|
|
+ </bean>
|
|
|
+
|
|
|
+ <!-- (事务管理)transaction manager, use JtaTransactionManager for global tx -->
|
|
|
+ <bean id="transactionManager"
|
|
|
+ class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
|
|
|
+ <property name="dataSource" ref="dataSource" />
|
|
|
+ </bean>
|
|
|
+
|
|
|
+ <!-- 创建SqlSessionFactory,同时指定数据源 -->
|
|
|
+ <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
|
|
|
+ <property name="dataSource" ref="dataSource" />
|
|
|
+ </bean>
|
|
|
+ <!-- 可通过注解控制事务 -->
|
|
|
+ <tx:annotation-driven />
|
|
|
+
|
|
|
+ <!-- Mapper接口所在包名,Spring会自动查找其下的Mapper -->
|
|
|
+ <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
|
|
|
+ <property name="basePackage" value="com.js.kbt.mapper" />
|
|
|
+ </bean>
|
|
|
+ <context:component-scan base-package="com.js.kbt.socket"/>
|
|
|
+<!-- <context:component-scan base-package="com.js.kbt.task"/> -->
|
|
|
+ <!-- 定时任务启动 -->
|
|
|
+ <task:annotation-driven />
|
|
|
+<!-- //进行定时任务的类,将其定义为一个bean -->
|
|
|
+ <bean id="myTask" class="com.js.kbt.task.MyTask"></bean>
|
|
|
+ <task:scheduled-tasks>
|
|
|
+ <task:scheduled ref="myTask" method="doTask" fixed-rate="1200000" />
|
|
|
+ </task:scheduled-tasks>
|
|
|
+ <bean id="helloServer" class="com.js.kbt.socket.HelloServer" scope="singleton" init-method="startServer" destroy-method="shutdown"/>
|
|
|
+ <bean id="userHandler" class="com.js.kbt.socket.UserHandler" scope="prototype"/>
|
|
|
+</beans>
|