SSH框架整合所需jar包及文件配置

Hibernate

  版本:hibernate-release-4.3.8.Final

  核心jar包:\lib\required

  antlr-2.7.7

  dom4j-1.6.1

  hibernate-commons-annotations-4.0.5.Final

  hibernate-core-4.3.8.Final

  hibernate-jpa-2.1-api-1.0.0.Final

  jandex-1.1.0.Final

  javassist-3.18.1-GA

  jboss-logging-3.1.3.GA

  jboss-logging-annotations-1.2.0.Beta1

  jboss-transaction-api_1.2_spec-1.0.0.Final

  配置文件:

  XML配置方式——hibernate.cfg.xml

<!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
    "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
        <property name="dialect">org.hibernate.dialect.OracleDialect</property>
        <property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
        <property name="connection.url">jdbc:oracle:thin:@localhost:1521:orcl</property>
        <property name="connection.username">bin</property>
        <property name="connection.password">123</property>
    <!-- Echo all executed SQL to stdout -->
        <property name="show_sql">true</property>
        <property name="format_sql">true</property>
    <!-- mapping setting -->
        <mapping resource="lg0001/model/bean/account.hbm.xml"/>
        <mapping class="lg0001.model.bean.Company"/>
        <mapping class="lg0001.model.bean.Rolelimit"/>
    </session-factory>
</hibernate-configuration>

  属性配置方式——hibernate.properties

dialect=org.hibernate.dialect.OracleDialect
connection.driver_class=oracle.jdbc.driver.OracleDriver
connection.url=jdbc:oracle:thin:@localhost:1521:orcl
connection.username=bin
connection.password=123
show_sql=true
format_sql=true

  工具类:HibernateUtil.java

package util;

import org.hibernate.SessionFactory;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;

public class HibernateUtil {

    private static final SessionFactory sessionFactory = buildSessionFactory();

    private static SessionFactory buildSessionFactory() {
        SessionFactory sf = null;
        try {
            Configuration cfg = new Configuration();//加载 properties配置
            cfg.configure();//加载xml配置,默认寻找名为hibernate.cfg.xml的配置文件
            ServiceRegistry sr = new StandardServiceRegistryBuilder().applySettings(cfg.getProperties()).build();
            sf = cfg.buildSessionFactory(sr);
        } catch (Throwable e) {
            System.err.println("Initial SessionFactory creation failed!" + e);
            throw new ExceptionInInitializerError(e);
        }
        return sf;
    }

    public static SessionFactory getSessionFactory() {
        return sessionFactory;
    }

}

  注意:

  1.如果配置文件的文件名是自定义的(例如:hibernate.xml),则需要使用以下方式读取:cfg.configure("hibernate.xml")

  2.Hibernate首先读取属性文件(properties文件)中的配置,再读取xml配置文件中的配置。xml配置覆盖properties配置。

  3.属性文件不能配置使用的映射文件。

Spring

  版本:3.1.1

   核心jar包:

   commons-logging-1.1.1

   struts2-spring-plugin-2.3.3

   org.springframework.aop-3.1.1.RELEASE

  …….asm-3.1.1……

  beans

  context

  core

  expression

  jdbc

  orm

  transaction

  web

  配置文件:

  spring.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"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd">

    <bean id="loginAction" class="lg0001.model.action.LoginAction" scope="prototype">
        <property name="logic" ref="loginLogic" />
    </bean>

    <bean id="loginLogic" class="lg0001.model.logic.LoginLogic" scope="singleton">
        <property name="dao" ref="userDao" />
    </bean>

    <bean id="userDao" class="lg0001.model.dao.LoginDao" scope="singleton" />

</beans>

  web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
    http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
  <context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>classpath:spring.xml</param-value>
  </context-param>
  <listener>
      <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
  </filter>
  <filter-mapping>
      <filter-name>struts2</filter-name>
      <url-pattern>/*</url-pattern>
  </filter-mapping>
  <welcome-file-list>
    <welcome-file>lg0001/lg0001.jsp</welcome-file>
  </welcome-file-list>
</web-app>

Struts2

   版本:struts-2.3.16.3

  核心jar包:\apps\struts2-blank\WEB-INF\lib

  asm-3.3

  asm-commons-3.3

  asm-tree-3.3

  commons-fileupload-1.3.1

  commons-io-2.2

  commons-lang3-3.1

  commons-logging-1.1.3

  freemarker-2.3.19

  javassist-3.11.0.GA

  log4j-1.2.17

  ognl-3.0.6

  struts2-core-2.3.16.3

  xwork-core-2.3.16.3

  配置文件:

  struts.xml

<?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.enable.DynamicMethodInvocation" value="true" />
    <constant name="struts.devMode" value="true" />
    <constant name="struts.objectFactory" value="spring" />
    <include file="buy0001/configurations/struts_buy0001.xml"/>
    <include file="lg0001/configurations/struts_lg0001.xml"/>
</struts>

  struts_lg0001.xml

<?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.objectFactory" value="spring" />
    <package name="lg0001" namespace="/lg0001" extends="struts-default">
        <action name="doLogin" class="loginAction">
            <result name="success" type="redirect">
                <param name="location">/in0001/in0001.jsp</param>
            </result>
            <result name="error">/lg0001/lg0001.jsp</result>
            <result name="validateCode" type="stream">
                <param name="contentType">image/jpeg</param>
                <param name="inputName">inputStream</param>
            </result>
        </action>
    </package>
</struts>

  web.xml的配置见上面Spring部分。

Annotation

   所需jar包:\Tomcat7.0\lib

  servlet-api

Oracle

   核心jar包:\oracle\product\11.2.0\dbhome_1\jdbc\lib

  ojdbc6

  

  

 

  

   

  

  

  

时间: 2024-10-25 02:05:03

SSH框架整合所需jar包及文件配置的相关文章

Struts2.3.4 、Hibernate3.6 和Spring3.1.2整合所需jar包列表

antlr-2.7.6.jaraopalliance.jarasm-3.3.jarasm-commons-3.3.jarasm-tree-3.3.jaraspectjrt.jaraspectjweaver.jarc3p0-0.9.1.2.jarcglib-nodep-2.1_3.jarcommons-collections-3.1.jarcommons-fileupload-1.2.2.jarcommons-io-2.0.1.jarcommons-lang3-3.1.jarcommons-log

SSH框架整合配置所需JAR包(SSH整合)

Hibernate Jar: 1.hibernate3.jar,这个是hibernate3.0的核心jar包,没的选,像我们常用的Session,Query,Transaction都位于这个jar文件中,必要. 2.cglib-2.1.3.jar,CGLIB库,Hibernate用它来实现PO字节码的动态生成,非常核心的库,必要. 3.asm.jar ASM字节码库 如果使用"cglib"则必要,必要 4.asm-attrs.jar ASM字节码库 如果使用"cglib&qu

SSH框架整合jar包时的注意事项

SSH框架整合jar包时的注意事项: 在将三个框架所需的jar整合到一起后,要看一下有没有相同类型但是版本不同的jar包,如果有的话,需要把低版本的jar包删除掉,否则会报错.我这里整合的时候javassit的jar出现了两个不同版本的,需要把低版本的删除掉. 原文地址:https://www.cnblogs.com/wyhluckdog/p/10139375.html

搭建SSH框架所需Jar包及其解释

SSH2 ----struts2.1.8---- struts2-core-2.1.8.1.jar struts2核心包 struts2-json-plugin-2.1.8.1.jar struts2的json插件--var s = {name:"zhangs",age:"18"} struts2-spring-plugin-2.1.8.1.jar 与spring集成插件 xwork-core-2.1.6.jar struts2的构建基础jar struts2-co

条理清晰的搭建SSH环境之添加所需jar包

一.首先介绍要添加框架环境: JUnit Struts2 Hibernate Spring (1)配置JUnit /**-------------------------添加JUnit-------------------------------*/ 右击Web项目--->Build Path--->Add Libraries--->在"Add Libraries窗口选择Junit"--- --->Next--->选择版本JUnit 4 /**------

ssh框架整合实例

MyEclipse开发SSH(Struts+Spring+Hibernate)入门 Spring技术   2009-02-03 15:59   阅读328   评论0 字号: 大大  中中  小小 2008-01-31 01:31 (本文参考自 oksonic 的"Struts+Spring+Hibernate练习(完整)") 源码下载:http://ishare.iask.sina.com.cn/cgi-bin/fileid.cgi?fileid=2857703 注意:这个实例要加入

SSH框架整合中的备忘记录

整合ssh需要的jar包: struts2-core.jar struts2-convention-plugin-2.*.*.*.jar ------是struts2的注解开发jar包 struts2-spring-plugin-2.*.*.*.jar ------struts2用于整合spring的jar包 (spring中也有一个 spring-struts2的jar包,也是用来整合两个框架的jar包,引入其中一个可以) Hibernate框架开发的响应的jar: hibernate-cor

spring+springMvc+struts的SSH框架整合

1.建立一个web项目 2.导入SSH框架所需jar包 3.配置web.xml文件 <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation=&

SSH框架整合过程总结

---------------------siwuxie095 SSH 框架整合过程总结 (一)导入相关 jar 包(共 41 个) 1.导入 Spring 的核心 jar 包和日志相关的 jar 包(6 个) Commons Logging 下载链接: http://commons.apache.org/proper/commons-logging/download_logging.cgi LOG4J 下载链接: https://www.apache.org/dist/logging/log4