Set applicationContext. xml in the configuration file as follows:
<? Xml version = "1.0" encoding = "UTF-8"?>
<Beans
Xmlns = "http://www.springframework.org/schema/beans"
Xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"
Xsi: schemaLocation = "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<Bean id = "dataSource" class = "org. apache. commons. dbcp. BasicDataSource">
<! -- Connect to MySQL -->
<Property name = "driverClassName" value = "com. mysql. jdbc. Driver"> </property>
<Property name = "url" value = "jdbc: mysql: // localhost: 3306/mytest"> </property>
<Property name = "username" value = "root"> </property>
<Property name = "password" value = "root"> </property>
<! -- Connect to Oracle
<Property name = "driverClassName" value = "oracle. jdbc. driver. OracleDriver"> </property>
<Property name = "url" value = "jdbc: oracle: thin :@ localhost: 1521: orcl"> </property>
<Property name = "username" value = "scott"> </property>
<Property name = "password" value = "tiger"> </property>
-->
<! -- Connect to SQL Server
<Property name = "driverClassName" value = "com. microsoft. sqlserver. jdbc. SQLServerDriver"> </property>
<Property name = "url" value = "jdbc: sqlserver: // localhost: 1433; databaseName = test"> </property>
<Property name = "username" value = "sa"> </property>
<Property name = "password" value = "yuji"> </property>
-->
<Property name = "maxActive" value = "100"> </property>
<Property name = "maxIdle" value = "30"> </property>
<Property name = "maxWait" value = "500"> </property>
<Property name = "defaultAutoCommit" value = "true"> </property>
</Bean>
<Bean id = "sessionFactory" class = "org. springframework. orm. hibernate3.LocalSessionFactoryBean">
<Property name = "dataSource" ref = "dataSource"> </property>
<Property name = "hibernateProperties">
<Props>
<! -- MySQL Dialect -->
<Prop key = "hibernate. dialect"> org. hibernate. dialect. MySQLDialect </prop>
<! -- Oracle Dialect
<Prop key = "hibernate. dialect"> org. hibernate. dialect. OracleDialect </prop>
-->
<! -- SQL Server Dialect
<Prop key = "hibernate. dialect"> org. hibernate. dialect. SQLServerDialect </prop>
-->
<Prop key = "hibernate. show_ SQL"> true </prop>
</Props>
</Property>
<Property name = "mappingResources">
<List>
<Value> com/test/bean/User. hbm. xml </value>
</List>
</Property>
</Bean>
<Bean id = "userDao" class = "com. test. dao. impl. UserDAOImpl" scope = "singleton">
<Property name = "sessionFactory">
<Ref bean = "sessionFactory"/>
</Property>
</Bean>
<Bean id = "userService" class = "com. test. service. impl. UserServiceImpl">
<Property name = "userDao" ref = "userDao"> </property>
</Bean>
<Bean id = "saveUserAction" class = "com. test. action. user. SaveUserAction" scope = "prototype">
<Property name = "service" ref = "userService"> </property>
</Bean>
<Bean id = "listUserAction" class = "com. test. action. user. ListUserAction" scope = "prototype">
<Property name = "service" ref = "userService"> </property>
</Bean>
<Bean id = "removeUserAction" class = "com. test. action. user. RemoveUserAction" scope = "prototype">
<Property name = "service" ref = "userService"> </property>
</Bean>
</Beans>