一、电商-ssh环境配置

搭建开发环境

1.创建一个web工程

2.引入jar包和配置文件:

  *struts2:

    *jar包:

      struts-2.3.34\apps\struts2-blank.war\WEB-INF\lib\*.jar

      struts-2.3.34\lib\struts2-json-plugin-2.3.34

      struts-2.3.34\lib\struts2-spring-plugin-2.3.34

    *配置文件:

      *web.xml

        <!-- 配置struts2的核心过滤器 -->
        <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>

         *strut2.xml

    *spring:

      *jar包:

       spring开发最基本jar包:

        spring-beans-4.0.0.RELEASE.jar

        spring-context-4.0.0.RELEASE.jar

        spring-core-4.0.0.RELEASE.jar

        spring-expression-4.0.0.RELEASE.jar

        com.springsource.org.apache.log4j-1.2.15.jar

        com.springsource.org.apache.commons.logging-1.1.1.jar

      AOP开发:

        spring-aop-4.0.0.RELEASE.jar

        spring-aspects-4.0.0.RELEASE.jar

        com.springsource.org.aopalliance-1.0.0.jar

        com.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar

      Spring Jdbc开发:

        spring-jdbc-4.0.0.RELEASE.jar

·         spring-tx-4.0.0.RELEASE.jar

  `    Spring事务管理:

        spring-tx-4.0.0.RELEASE.jar

       Spring整合其他ORM框架:

        spring-orm-4.0.0.RELEASE.jar

      Spring在web中应用:

        spring-web-4.0.0.RELEASE.jar

      Spring整合Junit测试:

        spring-test-4.0.0.RELEASE.jar

    *配置文件:

      *web.xml      

        <!-- 配置spring的核心监听器 -->
        <listener>
          <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>

        <context-param>
           <param-name>contextConfigLocation</param-name>
           <param-value>classpath:applicationContext.xml</param-value>
        </context-param>

      *applicationContext.xml

      *log4j.properties*******************************************************************

    *Hibernate:

      *jar包:

        *hibernate

        *slf4j-log4j的整合的jar包

        *数据库驱动

        *连接池:(c3p0)

      *配置文件:

        *没有bibernate的核心文件的方式整合

        *映射文件:

3.配置基本配置信息

  *C3P0连接池

    *引入外部属性文件:

      *jdbc.properties

    *配置连接池:

            <!-- 配置连接池 -->
            <!-- 引入外部属性文件 -->
            <context:property-placeholder location="classpath:jdbc.properties"/>
            <!-- 配置C3P0连接池 -->
            <bean id="datasource"   class="com.mchange.v2.c3p0

          .ComboPooledDataSource">
                <property name="driverClass" value="${jdbc.driver}"/>
                <property name="jdbcUrl" value="${jdbc.url}"/>
                <property name="user" value="${jdbc.user}"/>
                   <property name="password" value="${jdbc.password}"/> 
           </bean>

  *事务管理:

     <!-- 事务管理 -->
          <!-- 事务管理器 -->
          <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManage">
             <property name="sessionFactory" ref="sessionFactory"/>  
          </bean>
      
          <!-- 开启注解事务 -->
          <tx:annotation-driven transaction-manager="transactionManager"/>

  *hibernate相关信息:

               <!-- hibernate的相关信息 -->
         <bean id="sessionFactory"  class="org.springframework.orm.hibernate5.

          LocalSessionFactoryBean">
          <!-- 注入连接池 -->
               <property name="dataSource" ref="dataSource"/>
               <!-- 配置Hibernate的其他的属性 -->
               <property name="hibernateProperties">
                    <props>
                        <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
                        <prop key="hibernate.show_sql">true</prop>
                        <prop key="hibernate.format_sql">true</prop>
                        <prop key="hibernate.connection.autocommit">false</prop>
                        <!-- 开机自动生成表 -->
                        <prop key="hibernate.hbm2ddl.auto">update</prop>
                     </props>
                  </property>
                  <!-- 配置hibernate的映射文件 -->

       </bean>

        

        

        

      

猜你喜欢

转载自www.cnblogs.com/lening206/p/9122149.html