在配置文件applicationContext.xml设置如下:
<?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">
<!-- 连接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>
<!-- 连接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>
-->
<!-- 连接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的方言-->
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<!-- Oracle的方言
<prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>
-->
<!-- SQL Server的方言
<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>
分享到:
相关推荐
applicationContext.xml 详细配置
ssh配置applicationContext.xml 是使用使用该框架的必须的、基础的配置,文件中配置了与数据库的连接,事物等,使项目能够对数据库进行操作。
Spring配置文件ApplicationContext,内容齐全,有需要的可以下载。
applicationContext.xml完美配置
ssh框架事务管理applicationContext.xml配置文件
Spring Web MVC开发 xml配置文件格式,无bean之类 Spring Web MVC开发配置文件 applicationContext
SpringMVC整合Shiro,Shiro是一个强大易用的Java安全框架,提供了...配置applicationContext-shiro.xml 1. 配置authorizingRealm 2.Shiro Filter 设置拦截的内容和登录页面和成功、失败页面 3.配置securityManager ...
ApplicationContext ac = new ClassPathXmlApplicationContext("spring/applicationContext-jms-producer.xml"); //获取生产者发送消息服务接口 MessageSender messageSender = (MessageSender)ac.getBean...
《Spring的数据源配置文件模板》applicationContext.zip
Quartz任务调度框架(启动定时任务框架) spring配置applicationContext.xml文件位置
使用struts2(json-plugin) + spring2 + ibatis2 + extjs2.2 + mysql5.0架构开发的图书管理系统,对学习struts2,json-plugin,spring2,ibatis2, ...* 部署时,注意修改相应的数据源配置applicationContext-common.xml
a. 配置applicationContext-wsclient.xml; Spring管理第三方WebService实例bean Jaxws-client配置代码 b. 生成第三方WebService接口文件;(提供系统自动生成) 自动生成代码 c. 页面调用Action请求,Action中...
spring2.5的applicationContext配置文件.
struts.xml和applicationContext.xml、web.xml的配置
applicationContext.xml详解
使用myeclipse8.5搭建SSH后,将struts.xml和applicationContext.xml移动到别的地方,示例中为webroot下的config文件夹中,web.xml中需要做的修改示例。其中对于返回上一层方式不同的myeclipse可能不同,如有的用../...
ApplicationContext 1.ApplicationContext是一个接口,提供了访问spring容器的API 2.ClassPathXmlApplicationContext是一个类,实现了上述功能 3.ApplicationContext的顶层接口是BeanFactory 4.BeanFactory定义...
这是一些配置文件,可以作为参考,个人感觉很方便的学习方法
NULL 博文链接:https://hs295160903.iteye.com/blog/2314235