<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      新手使用idea整合Spring+Struts+Hibernate項目

      項目所需jar下載:

      https://download.csdn.net/download/weixin_44906002/12505287

      1、如圖,使用idea新建一個struts的web項目,點擊next,編輯項目名稱,點擊finish

      2、在web/WEB-INF下創建lib文件夾,導入下載好的jar包,然后鼠標右鍵點擊lib,選擇添加為庫

      3、構建如下圖的項目結構: 

       4、編輯beans.xml,該配置文件可以創建項目的時候選擇spring項目,自動創建,路徑隨意,一般自動創建的applicationContext.xml在web/WEB-INF文件夾下面。

      對beans.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:context="http://www.springframework.org/schema/context"
       5        xmlns:tx="http://www.springframework.org/schema/tx"
       6        xmlns:aop="http://www.springframework.org/schema/aop"
       7        xsi:schemaLocation="http://www.springframework.org/schema/beans
       8        http://www.springframework.org/schema/beans/spring-beans.xsd
       9        http://www.springframework.org/schema/context
      10        http://www.springframework.org/schema/context/spring-context-4.1.xsd
      11        http://www.springframework.org/schema/cache
      12        http://www.springframework.org/schema/cache/spring-cache.xsd
      13        http://www.springframework.org/schema/aop
      14        http://www.springframework.org/schema/aop/spring-aop.xsd
      15        http://www.springframework.org/schema/tx
      16        http://www.springframework.org/schema/tx/spring-tx.xsd">
      17     <!--開啟包掃描-->
      18     <context:component-scan base-package="com.cheng.*"/>
      19     <!--配置數據源,這里使用的是c3p0連接池-->
      20     <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
      21         <property name="driverClass" value="com.mysql.cj.jdbc.Driver"/>
      22         <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/shape?userUnicode=true&amp;characterEncoding=utf-8"/>
      23         <property name="user" value="root"/>
      24         <property name="password" value="lijc19980218"/>
      25     </bean>
      26     <!--配置Hibernate的會話工廠bean-->
      27     <bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
      28         <!--注入數據源-->
      29         <property name="dataSource" ref="dataSource"/>
      30         <!--Hibernate配置文件位置-->
      31         <property name="configLocation" value="classpath:hibernate.cfg.xml"/>
      32     </bean>
      33     
      34     <!--配置事務管理器,將事務管理交給spring-->
      35     <bean id="txManger" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
      36         <property name="sessionFactory" ref="sessionFactory"/>
      37     </bean>
      38     <!--定義事務通知-->
      39     <tx:advice id="txAdvice" transaction-manager="txManger">
      40         <tx:attributes>
      41             <!--事務方法-->
      42             <tx:method name="save*" propagation="REQUIRED"/>
      43             <tx:method name="add*" propagation="REQUIRED"/>
      44             <!--...-->
      45         </tx:attributes>
      46     </tx:advice>
      47     
      48     <!--配置AOP-->
      49     <aop:config>
      50         <aop:pointcut id="service" expression="execution(* com.cheng.service..*.*(..))"/>
      51         <aop:advisor advice-ref="txAdvice" pointcut-ref="service"/>
      52     </aop:config>
      53 
      54 </beans>

      5、配置hibernate.cfg.xml文件

       1 <?xml version='1.0' encoding='utf-8'?>
       2 <!DOCTYPE hibernate-configuration PUBLIC
       3         "-//Hibernate/Hibernate Configuration DTD//EN"
       4         "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
       5 <hibernate-configuration>
       6     <session-factory>
       7         <!--映射文件-->
       8         <mapping resource="com/cheng/bean/circle.hbm.xml"/>
       9     </session-factory>
      10 </hibernate-configuration>

      6、配置struts.xml,讓spring融合struts

       1 <?xml version="1.0" encoding="UTF-8"?>
       2 
       3 <!DOCTYPE struts PUBLIC
       4         "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
       5         "http://struts.apache.org/dtds/struts-2.5.dtd">
       6 
       7 <struts>
       8     <!--配置struts為開發模式-->
       9     <constant name="struts.devMode" value="true"/>
      10     <!--配置主題為簡單主題-->
      11     <constant name="struts.ui.theme" value="simple"/>
      12     <!--配置請求后綴-->
      13     <constant name="struts.action.extension" value="do"/>
      14     <!--使用Spring的對象工廠-->
      15     <constant name="struts.objectFactory" value="spring"/>
      16     <package name="default" extends="struts-default" namespace="/">
      17         
      18     </package>
      19 </struts>

      7、配置web.xml

       1 <?xml version="1.0" encoding="UTF-8"?>
       2 <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
       3          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       4          xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
       5          version="4.0">
       6     <context-param>
       7         <param-name>contextConfigLocation</param-name>
       8         <param-value>classpath:beans.xml</param-value>
       9     </context-param>
      10     <listener>
      11         <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
      12     </listener>
      13     <filter>
      14         <filter-name>struts2</filter-name>
      15         <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
      16     </filter>
      17     <filter-mapping>
      18         <filter-name>struts2</filter-name>
      19         <url-pattern>/*</url-pattern>
      20     </filter-mapping>
      21 </web-app>

      <context-param></context-param>存放的是beans.xm配置文件路徑,添加監聽以便于在部署Web項目時,啟動和初始化Spring容器。

      8、hibernate映射文件,例如:

       1 <?xml version='1.0' encoding='UTF-8'?>
       2 <!DOCTYPE hibernate-mapping PUBLIC
       3         "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
       4         "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
       5 
       6 <hibernate-mapping>
       7     <class name="完全限定類名" table="映射數據庫表名">
       8         <id name="主鍵">
       9             <generator class="assigned"></generator>
      10         </id>
      11 
      12         <property name="其他字段"></property>
      13 
      14     </class>
      15 
      16 </hibernate-mapping>

       

      然后爽一波試試好不好使

       

      posted on 2020-06-08 16:33  月落長空  閱讀(785)  評論(0)    收藏  舉報

      主站蜘蛛池模板: 国产成人无码精品久久久露脸| 亚洲成av人片无码天堂下载| 久久国产精品福利一区二区三区| 涟水县| 在线播放亚洲人成电影| 美女无遮挡免费视频网站| 精品久久久久久无码人妻蜜桃 | 磐安县| 亚洲国产精品男人的天堂| 亚洲综合小综合中文字幕| 成人影片一区免费观看| 久久国产成人午夜av影院| 末发育娇小性色xxxxx视频| av综合亚洲一区二区| 国产精品人妻系列21p| 国产精品久久久久久无毒不卡| 极品少妇无套内射视频| 年轻女教师hd中字3| 亚洲V天堂V手机在线| 呼图壁县| 少妇爽到呻吟的视频| 中文字幕精品久久久久人妻红杏1| 亚洲综合色区另类av| 国产综合色产在线视频欧美| 99久久精品费精品国产一区二| 人妻少妇精品视频专区| 国产精品亚洲二区在线看| 亚洲高清国产拍精品网络战| 中文字幕av无码免费一区| 中文熟妇人妻av在线| 九九热在线视频观看最新| 18禁超污无遮挡无码网址| 麻花传媒在线观看免费| 婷婷久久香蕉五月综合加勒比 | 激情啪啪啪一区二区三区| 亚洲成人av在线资源网| 国偷自产av一区二区三区| 国产在线自拍一区二区三区| 日本少妇自慰免费完整版| 久久人人爽人人爽人人片av| 天堂www在线中文|