| 4500 |
mandeep.dh |
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
2 |
<!-- Copyright 2010 The myBatis Team Licensed under the Apache License, Version
|
|
|
3 |
2.0 (the "License"); you may not use this file except in compliance with
|
|
|
4 |
the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
|
5 |
Unless required by applicable law or agreed to in writing, software distributed
|
|
|
6 |
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
|
|
|
7 |
OR CONDITIONS OF ANY KIND, either express or implied. See the License for
|
|
|
8 |
the specific language governing permissions and limitations under the License. -->
|
|
|
9 |
|
|
|
10 |
<beans xmlns="http://www.springframework.org/schema/beans"
|
|
|
11 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
|
|
|
12 |
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
|
|
|
13 |
xmlns:context="http://www.springframework.org/schema/context"
|
|
|
14 |
xsi:schemaLocation="
|
|
|
15 |
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
|
|
|
16 |
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
|
|
17 |
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
|
|
|
18 |
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
|
|
|
19 |
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
|
|
|
20 |
|
|
|
21 |
<context:property-placeholder location="classpath:jdbc.properties" />
|
|
|
22 |
|
|
|
23 |
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
|
|
|
24 |
<!-- JDBC connection properties -->
|
|
|
25 |
<property name="driverClassName" value="${jdbc.driverClassName}" />
|
|
|
26 |
<property name="url" value="${jdbc.url}" />
|
|
|
27 |
<property name="username" value="${jdbc.username}" />
|
|
|
28 |
<property name="password" value="${jdbc.password}" />
|
|
|
29 |
|
|
|
30 |
<!-- Pool size related properties -->
|
|
|
31 |
<!-- The initial number of connections that are created when the pool is
|
|
|
32 |
started. -->
|
|
|
33 |
<property name="initialSize" value="2" />
|
|
|
34 |
|
|
|
35 |
<!-- The maximum number of active connections that can be allocated from
|
|
|
36 |
this pool at the same time, or negative for no limit. -->
|
|
|
37 |
<property name="maxActive" value="16" />
|
|
|
38 |
|
|
|
39 |
<!-- The maximum number of milliseconds that the pool will wait (when there
|
|
|
40 |
are no available connections) for a connection to be returned before throwing
|
|
|
41 |
an exception, or -1 to wait indefinitely. -->
|
|
|
42 |
<property name="maxWait" value="10000" />
|
|
|
43 |
|
|
|
44 |
<!-- The SQL query that will be used to validate connections from this
|
|
|
45 |
pool before returning them to the caller. If specified, this query MUST be
|
|
|
46 |
an SQL SELECT statement that returns at least one row. -->
|
|
|
47 |
<property name="validationQuery" value="SELECT 1" />
|
|
|
48 |
|
|
|
49 |
<!-- The indication of whether objects will be validated before being borrowed
|
|
|
50 |
from the pool. If the object fails to validate, it will be dropped from the
|
|
|
51 |
pool, and we will attempt to borrow another. -->
|
|
|
52 |
<property name="testOnBorrow" value="false" />
|
|
|
53 |
|
|
|
54 |
<!-- The indication of whether objects will be validated by the idle object
|
|
|
55 |
evictor (if any). If an object fails to validate, it will be dropped from
|
|
|
56 |
the pool. -->
|
|
|
57 |
<property name="testWhileIdle" value="true" />
|
|
|
58 |
|
|
|
59 |
<!-- The minimum amount of time an object may sit idle in the pool before
|
|
|
60 |
it is eligable for eviction by the idle object evictor. Setting it to 2 hours. -->
|
|
|
61 |
<property name="minEvictableIdleTimeMillis" value="7200000" />
|
|
|
62 |
|
|
|
63 |
<!-- The number of milliseconds to sleep between runs of the idle object
|
|
|
64 |
evictor thread. When non-positive, no idle object evictor thread will be
|
|
|
65 |
run. Setting it to 15 minutes. -->
|
|
|
66 |
<property name="timeBetweenEvictionRunsMillis" value="1800000"></property>
|
|
|
67 |
|
|
|
68 |
<!-- Properties to prevent DB resource leaks -->
|
|
|
69 |
<!-- Flag to remove abandoned connections if they exceed the removeAbandonedTimout.
|
|
|
70 |
If set to true a connection is considered abandoned and eligible for removal
|
|
|
71 |
if it has been idle longer than the removeAbandonedTimeout. Setting this
|
|
|
72 |
to true can recover db connections from poorly written applications which
|
|
|
73 |
fail to close a connection. -->
|
|
|
74 |
<property name="removeAbandoned" value="true" />
|
|
|
75 |
|
|
|
76 |
<!-- Timeout in seconds before an abandoned connection can be removed. -->
|
|
|
77 |
<property name="removeAbandonedTimeout" value="300" />
|
|
|
78 |
|
|
|
79 |
<!-- Flag to log stack traces for application code which abandoned a Statement
|
|
|
80 |
or Connection. Logging of abandoned Statements and Connections adds overhead
|
|
|
81 |
for every Connection open or new Statement because a stack trace has to be
|
|
|
82 |
generated -->
|
|
|
83 |
<property name="logAbandoned" value="true" />
|
|
|
84 |
</bean>
|
|
|
85 |
|
|
|
86 |
<!-- transaction manager, use JtaTransactionManager for global tx -->
|
|
|
87 |
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
|
|
|
88 |
<property name="dataSource" ref="dataSource" />
|
|
|
89 |
</bean>
|
|
|
90 |
|
|
|
91 |
<!-- enable component scanning (beware that this does not enable mapper
|
|
|
92 |
scanning!) -->
|
|
|
93 |
<context:component-scan base-package="in.shop2020.warehouse.handler" />
|
|
|
94 |
|
|
|
95 |
<!-- enable autowire -->
|
|
|
96 |
<context:annotation-config />
|
|
|
97 |
|
|
|
98 |
<!-- enable transaction demarcation with annotations -->
|
|
|
99 |
<tx:annotation-driven />
|
|
|
100 |
|
|
|
101 |
<!-- define the SqlSessionFactory, notice that configLocation is not needed
|
|
|
102 |
when you use MapperFactoryBean -->
|
|
|
103 |
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
|
|
|
104 |
<property name="dataSource" ref="dataSource" />
|
|
|
105 |
<property name="configLocation" value="classpath:mybatis-config.xml" />
|
|
|
106 |
</bean>
|
|
|
107 |
|
|
|
108 |
<!-- scan for mappers and let them be autowired -->
|
|
|
109 |
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
|
|
|
110 |
<property name="basePackage" value="in.shop2020.warehouse.persistence" />
|
|
|
111 |
</bean>
|
|
|
112 |
</beans>
|