zoukankan      html  css  js  c++  java
  • SSH框架的搭建

    第一步:在数据库模式下新建一个数据库(如果已经新建过了就直接进行第二步)

      1.右键点击新建数据库

      2.选择您想要的数据库模版(如:MySql)

      3.填写好应该填写的内容,记得导JDBC驱动(要与选择的数据库模版相同)

      4.save password 然后Test Driver直到弹出数据库已成功建立连接对话框

    第二步:配置hibernate(转回Myeclipse Java Enterprise界面)

      1.可以点击支持注解

      2.copy  lib包

      3.选择您需要连接的数据库

      4.去掉创建sessionFactory的那个勾,点击finish

      

      5.add   show_sql为true(还可以添加jdbc.fetch_size 50和jdbc.batch_size 50)

    第三步:配置spring

      1.勾上前三个勾还有一个misc和一个web

      2.copy  lib包

      

    第四步:导入数据库(在数据库模式下)

      1.选中要导入的表,右键点击hibernate reverse enginerring

      2.选中工程,选中包,勾上前三个勾,next

      3.Id Generater:native    Enable many-to-many detection

      4.Include referenced tables(A->B/B->A)   finish

    第五步:配置struts(转回Myeclipse Java Enterprise界面)

      1.拷包(注意:一点要拷整合spring与struts的包)

      2.拷struts.xml与struts-2.1.7.dtd

      3.删掉asm2.2.3包(记得斩草除根)

    第六步:配置applicationContext.xml

      

     1 <?xml version="1.0" encoding="UTF-8"?>
     2 <beans xmlns="http://www.springframework.org/schema/beans"
     3     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     4     xmlns:util="http://www.springframework.org/schema/util"
     5     xmlns:p="http://www.springframework.org/schema/p"
     6     xmlns:aop="http://www.springframework.org/schema/aop"
     7     xmlns:tx="http://www.springframework.org/schema/tx"
     8     xmlns:context="http://www.springframework.org/schema/context"
     9     xsi:schemaLocation="
    10     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
    11     http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd
    12     http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
    13     http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
    14       http://www.springframework.org/schema/context 
    15     http://www.springframework.org/schema/context/spring-context-2.5.xsd">
    16 
    17     <!-- 自动扫描(注解) -->
    18     <context:component-scan base-package="com.service"></context:component-scan>
    19 
    20     <bean id="sessionFactory"
    21         class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
    22         <property name="configLocation"
    23             value="classpath:hibernate.cfg.xml">
    24         </property>
    25     </bean>
    26     <bean id="EmpDAO" class="com.dao.EmpDAO">
    27         <property name="sessionFactory">
    28             <ref bean="sessionFactory" />
    29         </property>
    30     </bean>
    31     <bean id="DepDAO" class="com.dao.DepDAO">
    32         <property name="sessionFactory">
    33             <ref bean="sessionFactory" />
    34         </property>
    35     </bean>
    36     
        <!--事物管理器-->
    37 <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> 38 <property name="sessionFactory" ref="sessionFactory"></property> 39 </bean>     <!--事物属性-->
    40 <tx:advice id="mytx"> 41 <tx:attributes> 42 <tx:method name="*"/> 43 </tx:attributes> 44 </tx:advice>     <!--织入-->
    45 <aop:config> 46 <aop:advisor advice-ref="mytx" pointcut="execution(* com.service.*.*(..))"/> 47 </aop:config> 48     <!--映射-->
    49 <bean id="empAction" class="com.action.EmpAction"> 50 <property name="empService" ref="empService"></property> 51 </bean> 52 53 <bean id="myInterceptor" class="com.action.MyInterceptor"></bean> 54 55 56 </beans>

    第七步:配置web.xml

      1.配置context param

      name:contextConfigLocation

      value:/WEB-INF/classes/app*.xml

      2.配置Filters

      name:openSession    class:openSessionInViewFilter               url-pattern:/*

      name:struts             class:strutsPrepareAndExecuteFilter       url-pattern:/*

      3.配置Listeners

      class:contextLoaderListener

    第八步:配置struts.xml

      要根据com.service和com.action来配

      

      

  • 相关阅读:
    LeetCode 623. Add One Row to Tree
    LeetCode 894. All Possible Full Binary Trees
    LeetCode 988. Smallest String Starting From Leaf
    LeetCode 979. Distribute Coins in Binary Tree
    LeetCode 814. Binary Tree Pruning
    LeetCode 951. Flip Equivalent Binary Trees
    LeetCode 426. Convert Binary Search Tree to Sorted Doubly Linked List
    LeetCode 889. Construct Binary Tree from Preorder and Postorder Traversal
    LeetCode 687. Longest Univalue Path
    LeetCode 428. Serialize and Deserialize N-ary Tree
  • 原文地址:https://www.cnblogs.com/xinxinjava/p/3021007.html
Copyright © 2011-2022 走看看