校园春色亚洲色图_亚洲视频分类_中文字幕精品一区二区精品_麻豆一区区三区四区产品精品蜜桃

主頁 > 知識庫 > ssh項目環(huán)境搭建步驟(web項目)

ssh項目環(huán)境搭建步驟(web項目)

熱門標簽:杭州語音電銷機器人軟件 地圖標注線上教程 電銷機器人好賣么 北票市地圖標注 四川保險智能外呼系統(tǒng)商家 杭州ai語音電銷機器人功能 高德地圖標注樣式 商洛電銷 電銷機器人是有一些什么技術

一、創(chuàng)建Web項目

二、加入Struts2支持(Struts-2.3.1.2版本)
1、   拷貝相關jar包到lib目錄下
(1)      struts2-core-2.3.1.2.jar
(2)      xwork-core-2.3.1.2.jar
(3)      ognl-3.0.4.jar
(4)      freemarker-2.3.18.jar
(5)      commons-logging-1.1.1.jar
(6)      commons-io-2.0.1.jar
(7)      commons-lang-2.5.jar
(8)      commons-fileupload-1.2.2.jar
(9)      javassist-3.11.0.GA.jar
(10)  struts2-spring-plugin-2.3.1.2.jar(整合Spring)

2、   配置web.xml文件
(1)      打開struts-2.3.1.2\apps\struts2-blank.war文件,查看其中web.xml配置
(2)      拷貝相關內容如下:

復制代碼 代碼如下:

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>

3、拷貝struts-2.3.1.2\apps\struts2-blank.war中的struts.xml文件到src下,大致內容如下:

復制代碼 代碼如下:

?xmlversion="1.0"encoding="UTF-8"?>
!DOCTYPEstrutsPUBLIC
"-//ApacheSoftwareFoundation//DTDStrutsConfiguration2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
struts>
constantname="struts.enable.DynamicMethodInvocation"value="false"/>
constantname="struts.devMode"value="false"/>
packagename="default"namespace="/"extends="struts-default">
default-action-refname="index"/>
global-results>
resultname="error">/error.jsp/result>
/global-results>
global-exception-mappings>
exception-mappingexception="java.lang.Exception"result="error"/>
/global-exception-mappings>
/package>
!--Addpackageshere-->
/struts>

4、增加相關的Xxx.hbm.xml文件到相應的包下面,內容大致如下:

復制代碼 代碼如下:

?xmlversion="1.0"encoding="UTF-8"?>
!DOCTYPEhibernate-mappingPUBLIC
"-//Hibernate/HibernateMappingDTD3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
hibernate-mappingpackage="com.oracle.po">
classname="CustomerBean"table="Customer">
idname="name"column="uname"/>
propertyname="password"column="upassword"/>
/class>
/hibernate-mapping>

三、增加Spring支持(Spring-framework-2.5.6版本)

1、拷貝相關jar包到lib目錄下
(1)spring.jar
(2)aspectjweaver.jar

2、在spring-framework-2.5.6\samples目錄下拷貝applicationContext.xml到src目錄下面,并修改文件名為applicationContext-common.xml,大致內容如下

復制代碼 代碼如下:

?xmlversion="1.0"encoding="UTF-8"?>
beansxmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
/beans>

3、修改web.xml配置文件,增加內容如下:

[coe]
!--增加監(jiān)聽,負責加載Spring文件-->
listener>
listener-class>org.springframework.web.context.ContextLoaderListener/listener-class>
/listener>
!--指定Spring的相關配置文件-->
context-param>
param-name>contextConfigLocation/param-name>
param-value>classpath:applicationContext-*.xml/param-value>
/context-param>
[/code]

四、增加Hibernate支持(Hibernate-distribution-3.6.10.Final)

1、拷貝相關包到lib下,包括hibernate-distribution-3.6.10.Final\lib\required文件夾下相關jar文件,jar如下列表:
(1)hibernate3.jar
(2)antlr-2.7.6.jar
(3)commons-collections-3.1.jar
(4)dom4j-1.6.1.jar
(5)jta-1.1.jar
(6)slf4j-api-1.6.1.jar
(7)hibernate-jpa-2.0-api-1.0.1.Final.jar
2、拷貝數(shù)據(jù)庫相關的jar文件到lib下,如:mysql-connector-java-5.1.18-bin.jar

五、整合Hibernate和Spring

1、修改applicationContext-common.xml文件,增加內容如下:

復制代碼 代碼如下:

!--1.配置DataSource數(shù)據(jù)源-->
beanid="dataSource"class="org.springframework.jdbc.datasource.DriverManagerDataSource">
propertyname="driverClassName"value="com.mysql.jdbc.Driver"/>
propertyname="url"value="jdbc:mysql://localhost:3306/MySSH"/>
propertyname="username"value="root"/>
propertyname="password"value="ok"/>
/bean>

!--2.配置SessionFactory-->
beanid="sessionFactory"class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
!--注入DataSource-->
propertyname="dataSource"ref="dataSource"/>
!--映射文件列表-->
propertyname="mappingResources">
list>
value>com/oracle/po/Customer.hbm.xml/value>
/list>
/property>
!--Hibernate相關屬性配置-->
propertyname="hibernateProperties">
props>
propkey="hibernate.dialect">org.hibernate.dialect.MySQLDialect/prop>
propkey="hibernate.show_sql">true/prop>
propkey="hibernate.hbm2ddl.auto">update/prop>
/props>
/property>
/bean>

!--3.定義事務管理器-->
beanid="transactionManager"class="org.springframework.orm.hibernate3.HibernateTransactionManager">
propertyname="sessionFactory"ref="sessionFactory"/>
/bean>

!--4.配置Spring對Hibernate的事務管理的傳播特性-->
tx:adviceid="txAdvice"transaction-manager="transactionManager">
tx:attributes>
tx:methodname="add*"propagation="REQUIRED"/>
tx:methodname="modify*"propagation="REQUIRED"/>
tx:methodname="del*"propagation="REQUIRED"/>
tx:methodname="*"read-only="true"/>
/tx:attributes>
/tx:advice>

!--5.配置Spring對Hibernate事務的切入點-->
aop:config>
aop:pointcutexpression="execution(*com.oracle.dao.*.*(..))"id="allManagerMethod"/>
aop:advisoradvice-ref="txAdvice"pointcut-ref="allManagerMethod"/>
/aop:config>

您可能感興趣的文章:
  • Django實現(xiàn)WebSSH操作物理機或虛擬機的方法
  • 詳解基于django實現(xiàn)的webssh簡單例子
  • 如何用Python和JS實現(xiàn)的Web SSH工具

標簽:西藏 云浮 貴州 江西 宿州 丹東 紅河 青島

巨人網(wǎng)絡通訊聲明:本文標題《ssh項目環(huán)境搭建步驟(web項目)》,本文關鍵詞  ssh,項目,環(huán)境,搭建,步驟,;如發(fā)現(xiàn)本文內容存在版權問題,煩請?zhí)峁┫嚓P信息告之我們,我們將及時溝通與處理。本站內容系統(tǒng)采集于網(wǎng)絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《ssh項目環(huán)境搭建步驟(web項目)》相關的同類信息!
  • 本頁收集關于ssh項目環(huán)境搭建步驟(web項目)的相關信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 乐昌市| 苗栗市| 西畴县| 仙游县| 海门市| 木兰县| 浦江县| 新巴尔虎右旗| 宁安市| 榆社县| 阿克| 前郭尔| 巴青县| 通许县| 克什克腾旗| 错那县| 广汉市| 明星| 玉田县| 鸡泽县| 台东市| 深水埗区| 东方市| 都江堰市| 扬中市| 白城市| 乌恰县| 乐安县| 化德县| 宣汉县| 恩施市| 永昌县| 青川县| 轮台县| 呼图壁县| 都匀市| 益阳市| 平罗县| 米林县| 依安县| 工布江达县|