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

来源:互联网 发布:sql语句实例教程 编辑:程序博客网 时间:2024/06/09 18:27
<?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>

0 0
原创粉丝点击