s2s3h3整合包说明

弄了一天,终于把3大框架整合完了,为了吃个大螃蟹(其实,估计有很多人都整合好了),
所要用到的包:
spring-framework-3.0.0.RELEASE-with-docs.zip;  
spring-framework-3.0.2.RELEASE-dependencies.zip;
struts-2.1.8.1-all.zip
hibernate-distribution-3.5.0-Final-dist.zip
slf4j-1.5.8.zip
mysql的jdbc包

 ----------------------------------------------------------------------------------------------------------------------------
下面的包,主要完成的是j2ee-OA使用的jar包整合。使之spring,hibernate,struts2都可以实现annotation注释配置
最终:只用一个beans.xml就可以代替hibernate,struts2,的所有配置文件
由于spring3.0将包分成了核心包和支持包,而且将spring2.5的一个spring.jar分成了若干的分支包。所以看起来spring导了很多包(其它也是如此,关于spring的jar有12MB之多)。
hibernate3.5的情况也是一样,在hibernate3.4将以前的由3个jar组合实现,变成了一个jar包。但是hibernate3.5的jar包中只有slf4j接口,没有其实现;所以还要下载slf4j-1.5.8.zip的jar包
这个版本是j2ee1.4用的,要导入jstl的支持包;j2ee1.5以上就不用了,j2ee1.5包里就有对jstl的支持。(但是要注意的是
如果服务器是tomcat,那么就必需使tomcat的版本在6.0以上,因为tomcat6.0以上的j2ee版本是1.5,而tomcat1.5x是1.4的,不持jstl,还要导入jstl的支持包(只不过导入后好像还是出错)。也就是说tomcat6.x对应j2ee1.5;tomcat5.x对应:1.4

---------------------------------------------------------------------------------------------------------------------------
jar包名称    所在位置    说明                                        
antlr-2.7.6.jar    hibernate/lib/required    解析HQL       
cglib-2.2.jar    hibernate\lib\bytecode\cglib    直接操作2进制码,注入加强      
com.springsource.org.apache.commons.dbcp-1.2.2.osgi.jar    spring-framework-3.0.2.RELEASE-dependencies\org.apache.commons\com.springsource.org.apache.commons.dbcp\1.2.2.osgi    Spring,dbcp数据库联接      (建议用c3p0)
com.springsource.org.apache.commons.pool-1.5.3.jar    spring-framework-3.0.2.RELEASE-dependencies\org.apache.commons\com.springsource.org.apache.commons.pool\1.5.3    Spring,dbcp pool数据库联接       
com.springsource.org.aspectj.tools-1.6.6.RELEASE.jar    spring-framework-3.0.2.RELEASE-dependencies\org.aspectj\com.springsource.org.aspectj.tools\1.6.6.RELEASE    AOP(支持)      
commons-collections-3.1.jar    hibernate-distribution-3.5.0-Final\lib\required    hibernate相关问题       
commons-fileupload-1.2.1.jar    struts-2.1.8.1\lib    web文件上传       
commons-io-1.3.2.jar    struts-2.1.8.1\lib    struts2信息传输       
commons-logging-1.0.4.jar    struts-2.1.8.1\lib    日志,struts2(spring)支持       
dom4j-1.6.1.jar    hibernate-distribution-3.5.0-Final\lib\required    hibernate的xml解析       
freemarker-2.3.13.jar    struts-2.1.8.1\lib    strut2用,一种模版技术       
hibernate-jpa-2.0-api-1.0.0.Final.jar    hibernate-distribution-3.5.0-Final\lib\required    jpa       
hibernate3.jar    hibernate-distribution-3.5.0-Final\    hibernate核心文件       
javassist-3.9.0.GA.jar    hibernate-distribution-3.5.0-Final\lib\required    Javassist是一个执行字节码操作的强而有力的驱动代码库       
jstl.jar    jsp的jstl支持    jsp的jstl支持(j2ee1.5的可以不用加)       
jta-1.1.jar    hibernate-distribution-3.5.0-Final\lib\required    JTA       
junit-4.8.2.jar    spring支持包,stust2,包有    日志,4.x支持annotation       
log4j-1.2.15.jar    spring支持包有    日志记录       
mysql-connector-java-5.1.0-bin.jar    这个自个找下吧,到处都有    数据库驱动       
ognl-2.6.11.jar    struts-2.1.8.1\lib    struts2的ognl支持     
org.springframework.aop-3.0.0.RELEASE.jar    spring-framework-3.0.0.RELEASE\dist    spring支持要用       
org.springframework.asm-3.0.0.RELEASE.jar    同上           
org.springframework.aspects-3.0.0.RELEASE.jar    同上           
org.springframework.web-3.0.0.RELEASE.jar    同上           
org.springframework.transaction-3.0.0.RELEASE.jar    同上           
org.springframework.orm-3.0.0.RELEASE.jar    同上           
org.springframework.jdbc-3.0.0.RELEASE.jar    同上           
org.springframework.expression-3.0.0.RELEASE.jar    同上           
org.springframework.core-3.0.0.RELEASE.jar    同上           
org.springframework.context.support-3.0.0.RELEASE.jar    同上           
org.springframework.context-3.0.0.RELEASE.jar    同上           
org.springframework.beans-3.0.0.RELEASE.jar    同上           
slf4j-api-1.5.8.jar    slf4j-1.5.8    slf4j接口       
slf4j-log4j12-1.5.8.jar    slf4j-1.5.8    slf4j转log4j的实现       
slf4j-nop-1.5.8.jar    slf4j-1.5.8    slf4j自身实现       
standard.jar    jsp支持jstl用           
struts2-codebehind-plugin-2.1.8.1.jar    struts-2.1.8.1\lib   struts2的annotation       
struts2-core-2.1.6.jar    struts-2.1.8.1\lib    struts2核心       
struts2-spring-plugin-2.1.8.1.jar    struts-2.1.8.1\lib    struts2支持spring       
xwork-core-2.1.6.jar    struts-2.1.8.1\lib    这个包的版本必需在2.1.6或以上,如果是2.1.4会报错(少一些类)       
----------------------------------------------------------------------------------------------------------------------------
包很多,基本的功能已实现。可能还有其它的功能要包的,要的时候再加,报错不可怕,只要认真观查就一定可以解决      
其配置文件如下:
-------------------------------------------------applicationContext-beans.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: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.5.xsd
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-2.5.xsd
           http://www.springframework.org/schema/aop
           http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
           http://www.springframework.org/schema/tx
           http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
    <context:annotation-config />
    <context:component-scan base-package="com.lovo" />
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
        destroy-method="close">
        <property name="driverClassName" value="com.mysql.jdbc.Driver" />
        <property name="url" value="jdbc:mysql://localhost:3306/spring" />
        <property name="username" value="root" />
        <property name="password" value="root" />
    </bean>   
    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <!--
        <property name="annotatedClasses">
            <list>
                <value>com.bjsxt.model.User</value>
                <value>com.bjsxt.model.Log</value>
            </list>
        </property>
         -->
         <property name="packagesToScan">
            <list>
                <value>com.lovo.cq.model</value>
            </list>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
                <prop key="hibernate.show_sql">true</prop>
                <prop key="hibernate.hbm2ddl.auto">update</prop>
            </props>
        </property>
    </bean>
    <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
        <property name="sessionFactory" ref="sessionFactory"></property>
    </bean>
<!--
    <bean id="txManager"
        class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>
    <aop:config>
        <aop:pointcut id="bussinessService"
            expression="execution(public * com.lovo.cq.control.*.*(..))" />
        <aop:advisor pointcut-ref="bussinessService"
            advice-ref="txAdvice" />
    </aop:config>
    <tx:advice id="txAdvice" transaction-manager="txManager">
        <tx:attributes>
            <tx:method name="exists" read-only="true" />
            <tx:method name="add*" propagation="REQUIRED"/>
        </tx:attributes>
    </tx:advice>
    -->
</beans>
---------------------------------------------------------------------------------------------------------------------------------
log4j.propertites这个就自个配吧;
--------------------------------------------------------------------------------------------------------------------------------
最后在web.xml加入:
---------------------------------------------------web.xml------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<web-app version="2.4"
 xmlns="http://java.sun.com/xml/ns/j2ee"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
 http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <!--
        <param-value>/WEB-INF/applicationContext-*.xml,classpath*:applicationContext-*.xml</param-value>
         -->
        <param-value>classpath:applicationContext-beans.xml</param-value>
    </context-param>
    <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
        <init-param>   
            <param-name>actionPackages</param-name>
            <param-value>com.lovo.cq.action</param-value>
          </init-param>
    </filter>
    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
</web-app>

posted on 2011-05-09 07:24  唐朝  阅读(729)  评论(0编辑  收藏  举报