SSH 是 Struts、Spring、Hibernate 三大框架的集成,採用四層架構:表示層、業務邏輯層、數據持久層、域模型層。本文記錄基於 JDK1.8、Tomcat 8.0、Eclipse 4.6 的完整搭建過程。

struts-2.3.30-all.zip,解壓後取 apps/struts2-blank.war/WEB-INF/lib/ 下所有 jar。
web.xml 註冊 Struts2 過濾器。
在 src 下建立四個包:
ssh.entity - 實體類ssh.dao - 數據訪問層ssh.service - 業務邏輯層ssh.action - Web 控制層
commons-logging.jar 和 struts2-spring-plugin.jar。
web.xml 添加 Spring 監聽器。
applicationContext.xml 配置 Bean。

lib/required 全部)及連接池 c3p0 相關 Jar。

EntityName.hbm.xml(命名規則:實體類名 + .hbm.xml)。
applicationContext.xml 中配置 SessionFactory、數據源、事務管理器,整合 Hibernate 配置。

至此,SSH 框架搭建完成,可進行業務開發。