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>
相关文章推荐
- struts-config.xml文件中配置数据源
- 在配置文件中获取数据源,然后在hibernate中用sql语句进行查询操作
- C#操作XML配置文件
- MFC操作XML配置文件的两种方式:DOM 和 MSXML
- xml基本操作和保存配置文件应用实例
- 在Spring的xml文件中配置数据源主要代码
- spring与jpa整合 简化persistence.xml配置文件 使用属性文件 数据源dbcp访问数据库
- Hibernate动态建表,通过hbm.xml配置文件创建数据表,进行数据库操作, 动态模型
- SpringMVC构建REST接口:第二篇 配置Maven的pom.xml文件
- 对Xml的文件操作,根据数据的配置和数据样式的定义,将结果字符输出
- 一个操作配置文件(Reg,ini,XML)的类
- ejb3.0数据源配置文件mysql-ds.xml oracle-ds.xml persistence.xml sqlserver-ds.xml
- [转载]JAVA高手解析XML配置文件的读取操作
- java对配置文件(XML/properties)的操作
- 编写XML作为配置文件的高级操作库
- C#操作xml配置文件最简单方法
- JAVA解析XML配置文件的读取操作
- springMVC+JAP整合彻底摆脱persistence.xml配置文件
- 10.29 springMVC 配置文件xml
- springMVC-mvc.xml 配置文件片段讲解 (未使用默认配置文件名)