SSH整合配置applicationContext.xml/hibernate.cfg.xml/struts.xml
来源:互联网 发布:网络银行业务体系架构 编辑:程序博客网 时间:2024/05/02 23:51
SSH整合时Spring中的applicationContext.xml 配置,本人在这里的Bean使用自动扫描与装配;使用注解方式管理事务;并且把Hibernate中的数据源信息放在了这里。
另外把JDBC的数据连接信息单独放在了一个名叫 jdbc.properties 中,然后引用外部文件$方法调用;(这样有利于未来更换数据库时只要单独修改 jdbc.properties即可)
1.以下为struts.xmll配置
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE struts PUBLIC"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN""http://struts.apache.org/dtds/struts-2.3.dtd"><struts><!-- 开发模式 --><constant name="struts.devMode" value="true"></constant><!-- 设置扩展名 --><constant name="struts.action.extension" value="com"></constant><!-- Action包块 --><package name="default" namespace="/" extends="struts-default"><action name="user" class="userAction" ><result></result></action></package> <!-- Add packages here --></struts>
2.以下为hibernate.cfg.xml配置
<?xml version='1.0' encoding='utf-8'?><!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"><hibernate-configuration><session-factory><!-- 方言 --><property name="dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property><!-- 显示SQL语句 --><property name="show_sql">true</property><!-- 自动建表 --><property name="hbm2ddl.auto">update</property><!-- 导入映射文件 --><mapping resource="com/qzh/entity/User.hbm.xml" /></session-factory></hibernate-configuration>
3.以下为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" xmlns:context="http://www.springframework.org/schema/context"xmlns:tx="http://www.springframework.org/schema/tx"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsdhttp://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"><!-- 自动扫描与装配 --><context:component-scan base-package="com.qzh.oa"></context:component-scan><!-- 引用外部文件 --><context:property-placeholder location="classpath:jdbc.properties"/><!-- 数据源dataSource --><bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"><property name="driverClass" value="${driverClass}"> </property><property name="jdbcUrl" value="${jdbcUrl}"> </property><property name="user" value="${user}"> </property><property name="password" value="${password}"> </property><!-- 其他配置 --><!--初始化时获取三个连接,取值应在minPoolSize与maxPoolSize之间。Default: 3 --><property name="initialPoolSize" value="3"></property><!--连接池中保留的最小连接数。Default: 3 --><property name="minPoolSize" value="3"></property><!--连接池中保留的最大连接数。Default: 15 --><property name="maxPoolSize" value="5"></property><!--当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。Default: 3 --><property name="acquireIncrement" value="3"></property><!-- 控制数据源内加载的PreparedStatements数量。如果maxStatements与maxStatementsPerConnection均为0,则缓存被关闭。Default: 0 --><property name="maxStatements" value="8"></property><!-- maxStatementsPerConnection定义了连接池内单个连接所拥有的最大缓存statements数。Default: 0 --><property name="maxStatementsPerConnection" value="5"></property><!--最大空闲时间,1800秒内未使用则连接被丢弃。若为0则永不丢弃。Default: 0 --><property name="maxIdleTime" value="1800"></property> </bean><!-- SessionFactory配置 --><bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"><property name="dataSource" ref="dataSource"></property><property name="configLocation" value="classpath:hibernate.cfg.xml"></property></bean><!-- 事务管理 --><tx:annotation-driven transaction-manager="transactionManager"/><bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"><property name="sessionFactory" ref="sessionFactory"></property></bean></beans>
4.整合使用到的JAR包
1 0
- SSH整合配置applicationContext.xml/hibernate.cfg.xml/struts.xml
- ssh整合!Struts.xml、hibernate与spring整合的applicationContext.xml、web.xml文件的配置!
- SSH配置:hibernate.cfg.xml
- hibernate.cfg.xml配置
- hibernate.cfg.xml配置
- hibernate.cfg.xml配置
- hibernate.cfg.xml配置
- hibernate.cfg.xml配置
- hibernate.cfg.xml配置
- Hibernate.cfg.xml 配置
- hibernate.cfg.xml配置
- hibernate.cfg.xml配置
- 配置hibernate.cfg.xml
- hibernate.cfg.xml配置
- hibernate.cfg.xml配置
- hibernate.cfg.xml 配置
- Struts整合Hibernate:Could not parse configuration: /hibernate.cfg.xml
- 整理hibernate.cfg.xml 与 applicationContext之间的配置方式
- 七牛iOS按顺序依次上传多张图片,一个block返回所有上传的url
- tomcat增加内存方法
- 离线应用
- android SoundRecorder (录音机)添加录音列表菜单项
- MFC单文档视图穷追猛打
- SSH整合配置applicationContext.xml/hibernate.cfg.xml/struts.xml
- hdu 3652 B-number(数位dp)
- popupwindow使用之异常:unable to add window -- token null is not valid
- 图解Android - 如何看Android的UML 图?
- python 全局变量的理解(global关键字)
- 选择报表工具软件的最新十大标准出炉
- 记录今天mysql导出活动
- 宽字符处理函数与普通函数对照表
- Python libvirt domain api