您的位置:首页 > 移动开发

SpringMVC配置文件applicationContext.xml操作数据源的配置

2014-06-11 21:30 204 查看
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-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/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"> <!-- <mvc:annotation-driven /> <context:component-scan base-package="jww.demo.controller*">
</context:component-scan> -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName">
<value>org.gjt.mm.mysql.Driver</value>
</property>
<property name="url">
<value>jdbc:mysql://localhost:3306/computer</value>
</property>
<property name="username">
<value>root</value>
</property>
<property name="password">
<value>mysqladmin</value>
</property>
</bean>

<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource">

</property>
<property name="mappingResources">
<list>
<value>jww/entity/User.hbm.xml</value>
<value>jww/entity/Computer.hbm.xml</value>
<value>jww/entity/Commentary.hbm.xml</value>
<value>jww/entity/BeginTime.hbm.xml</value>
<value>jww/entity/EndTime.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<!-- <bean id="personDaoImp" class="jww.demo.dao.imp.PersonDAOImp"> <property
name="sessionFactory" ref="sessionFactory"></property> </bean> <bean id="personService"
class="jww.demo.service.PersonService"> <property name="personDAOImp" ref="personDaoImp"></property>
</bean> -->
<bean id="hibernateUtil" class="jww.entity.HibernateUtil">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!--具体实现类的注入-->

<!-- 电脑详情 -->
<bean id="computerDao" class="jww.dao.ComputerDAO"></bean>
<bean id="computerService" class="jww.service.ComputerService">
<property name="computerDao" ref="computerDao"></property>
</bean>
<!-- 用户登录 -->
<bean id="userDao" class="jww.dao.UserDAO"></bean>
<bean id="userService" class="jww.service.UserService">
<property name="userDao" ref="userDao"></property>
</bean>
</beans>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息