`
yufenfei
  • 浏览: 798891 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

SSH项目常用到的XML配置

阅读更多

一,Hibernate3.3配置文件

<?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">

<!-- Generated by MyEclipse Hibernate Tools.                   -->
<hibernate-configuration>

<session-factory>
 <property name="dialect">
  org.hibernate.dialect.SQLServerDialect
 </property>
 <property name="connection.url">
  jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=oa
 </property>
 <property name="connection.username">sa</property>
 <property name="connection.password">server</property>
 <property name="connection.driver_class">
  com.microsoft.jdbc.sqlserver.SQLServerDriver
 </property>
 <property name="myeclipse.connection.profile">SQLServer</property>
  <property name="show_sql">true</property>
   <property name="hbm2ddl.auto">create</property>

 <mapping resource="com/wch/oa/po/User.hbm.xml" />

</session-factory>

</hibernate-configuration>

 

 

二、hibernate映射文件信息

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
   <class name="com.wch.hibernate.po.Student" table="STUDENT">
     <id name="id" column="ID" type="java.lang.Integer">
      <generator class="identity">
       
      </generator>
     </id>
     <property name="name" column="NAME" type="java.lang.String"></property>
     <property name="sex" column="SEX" type="java.lang.String"></property>
   </class>
</hibernate-mapping>

 

三、spring2.5的配置文件

<?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.xsd
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
           http://www.springframework.org/schema/context/spring-context-2.5.xsd">
    </beans>

 

四,完整配置

<?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:aop="http://www.springframework.org/schema/aop"
  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.0.xsd
            http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
            http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
  <bean id="dataSource"
  class="org.springframework.jdbc.datasource.DriverManagerDataSource" >
  <property name="driverClassName">
   <value>com.mysql.jdbc.Driver</value>
  </property>
  <property name="url">
   <value>jdbc:mysql://localhost:3306/newBlog</value>
  </property>
  <property name="username">
   <value>root</value>
  </property>

  <property name="password">
   <value>123456</value>
  </property>
 </bean>
 <bean id="sessionFactory"  class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
  <property name="dataSource">
   <ref local="dataSource" />
  </property>
  <property name="mappingResources">
  <list>
    <value>domain/message.hbm.xml</value>
   </list>
  </property>
  <property name="hibernateProperties">
   <props>
    <prop key="hibernate.show_sql">true</prop>
    <prop key="hibernate.format_sql">true</prop>
    <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
   </props>
  </property>
 </bean>
 <bean id="hibernateTemplate"
  class="org.springframework.orm.hibernate3.HibernateTemplate">
  <property name="sessionFactory">
   <ref local="sessionFactory" />
  </property>
 </bean>
 <bean id="transactionManager"
  class="org.springframework.orm.hibernate3.HibernateTransactionManager">
  <property name="sessionFactory">
   <ref local="sessionFactory" />
  </property>
  <property name="jdbcExceptionTranslator">
   <ref local="jdbcExceptionTranslator" />
  </property>
 </bean>
 <bean id="jdbcExceptionTranslator"
  class="org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator">
  <property name="dataSource">
   <ref local="dataSource" />
  </property>
 </bean>
</beans>

分享到:
评论

相关推荐

    SSH 项目框架搭建总结

    建立Web工程 * 导入需要的jar包 db:连接数据库的驱动包 hibernate:使用hibernate的jar包 jstl:java的标准标签库 junit:测试用到的jar包 spring:使用spring的jar包 ... struts.xml:struts2的配置文件

    struts XML 范例

    SSH中的struts得配置相当关键,很多的消息的传递和映射都要用到配置文件xml.这事一个开参考,我在项目中成功的用到过。

    Hibernate的配置文件

    在 javaweb 开发时会用到三大框架ssh 其中hibernate的使用要先配置一下映射的文件,你可以通过下载此代码作为参考

    ssh框架整合jar包

    structs2+spring+hibernate框架整合用到的jar包,这个是无缺失的,所有类都可以找到,jar包在WEB-INF/lib下可以找到,src里面有application.xml和Stucts2.xml的配置文件模版。欢迎下载使用

    j2ee SSH 整合笔记,献于新手。。

    合ssh 思路,用spring 管理 struts 的action ,与hibernate 的dao 持久层。 先载入jar包,在myeclipse里 增加 struts 增加 hibernate ...第二步 配置hibernate,我们打开hibernate.cfg.xml 设置一系列的参数。 ....

    spring五种事务配置demo

    测试spring事务管理 搭建了ssh框架的web工程 本工程用到的数据库表很简单 ... 第4种方式:使用tx标签配置的拦截器 详见spring-core-transaction-4.xml 第5种方式:全注解 详见spring-core-transaction-5.xml

    struts2+spring+hibernate整合示例

    a 加入支持 : 添加struts2.3.15 必需包 以及 struts json包(ajax要用到),spring整合struts2包,spring web 包,在src目录下建立struts.xml,复制头文件进去。将applicationContext.xml移到WEB-INF目录下。web容器...

    ssh-helper:ssh助手,可以很方便的在开发工具内部快捷的通过ssh登录远程linux服务器,并执行任何linux命令

    ssh-helperssh助手,可以很方便的在开发工具内部快捷的通过ssh登录远程linux服务器,并执行任何linux命令使用时,只需简单修改server.xml,将可能用到的linux服务器信息配置进来,然后运行Main即可

    ssh(structs,spring,hibernate)框架中的上传下载

    WEB-INF下的applicationContext.xml为Spring的配置文件,struts-config.xml为Struts的配置文件,file-upload.jsp为文件上传页面,file-list.jsp为文件列表页面。  本文后面的章节将从数据持久层->业务层->Web层的...

    SpringMVC-SSH全注解

    -- 配置那个类那个方法用到事务处理 --&gt; *" read-only="true" /&gt; *" propagation="REQUIRED" /&gt; *" propagation="REQUIRED" /&gt; *" propagation="REQUIRED" /&gt; *" propagation="REQUIRED" /&gt; ...

    基于Jsp的在线考试系统毕业设计论文

    在线考试系统用的是ssh稳定框架整合,为了保证用hibernate操作数据库不出错,所有的数据库表不是用mysql企业管理器或查询分析器来完成的,而是用hibernate的pojo类和hbm.xml文件导入的,然而,配置这些关联映射却很...

    JAVA上百实例源码以及开源项目源代码

     Java 3DMenu 界面源码,有人说用到游戏中不错,其实平时我信编写Java应用程序时候也能用到吧,不一定非要局限于游戏吧,RES、SRC资源都有,都在压缩包内。 Java zip压缩包查看程序源码 1个目标文件 摘要:Java源码...

    struts2.1.6+spring2.0+hibernate3.2常用配置包

    最近温习ssh2整合编程,顺便浏览下struts2有什么更新的消息,下载了新版本的struts2的2.1.8.1版,使用的是MyEclipse8.0开发,但是问题就随之而来了。MyEclipse8.0中自带的struts2版本是2.1.6,spring版本有2.0,2.5...

    Spring、SpringMVC和Mybatis框架整合包

    另外,MyBatis也可以替换Hibernate,正因为MyBatis的半自动特点,我们程序猿可以完全掌控SQL,这会让有数据库经验的程序猿能开发出高效率的SQL语句,而且XML配置管理起来也非常方便。 好了,如果你也认同我的看法,...

    JAVA上百实例源码以及开源项目

     Java 3DMenu 界面源码,有人说用到游戏中不错,其实平时我信编写Java应用程序时候也能用到吧,不一定非要局限于游戏吧,RES、SRC资源都有,都在压缩包内。 Java zip压缩包查看程序源码 1个目标文件 摘要:Java源码...

    成百上千个Java 源码DEMO 4(1-4是独立压缩包)

    Java 3DMenu 界面源码 5个目标文件 内容索引:Java源码,窗体界面,3DMenu Java 3DMenu 界面源码,有人说用到游戏中不错,其实平时我信编写Java应用程序时候也能用到吧,不一定非要局限于游戏吧,RES、SRC资源都有,都...

    java面试题

    73.6. 项目中用到的Spring中的切面编程最多的地方:声明式事务管理。 77 73.7. spring的事务如何配置 77 73.8. transaction有那几种实现(事务处理)(Spring) 79 73.9. Spring IoC 79 73.10. Spring AOP面向方面编程 ...

    千方百计笔试题大全

    201、你在项目中用到了xml技术的哪些方面?如何实现的? 48 202、用jdom解析xml文件时如何解决中文问题?如何解析? 48 203、编程用JAVA解析XML的方式. 49 204、EJB2.0有哪些内容?分别用在什么场合? EJB2.0和EJB1.1的...

    java面试宝典

    201、你在项目中用到了xml技术的哪些方面?如何实现的? 48 202、用jdom解析xml文件时如何解决中文问题?如何解析? 48 203、编程用JAVA解析XML的方式. 49 204、EJB2.0有哪些内容?分别用在什么场合? EJB2.0和EJB1.1的...

Global site tag (gtag.js) - Google Analytics