SSH整合步骤

1.创建动态web工程

2.整合spring

-加入jar:

spring-aop-4.0.0.RELEASE.jar

spring-aspects-4.0.0.RELEASE.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

spring-jdbc-4.0.0.RELEASE.jar

spring-orm-4.0.0.RELEASE.jar

spring-tx-4.0.0.RELEASE.jar

spring-web-4.0.0.RELEASE.jar

spring-webmvc-4.0.0.RELEASE.jar

commons-logging-1.1.3.jar

com.springsource.net.sf.cglib-2.2.0.jar

com.springsource.org.aopalliance-1.0.0.jar

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

log4j.jar

-在类目录下创建log4j.xml文件

SSH整合步骤

-在类目录下创建application.xml文件,配置springIOC容器

-在web.xml文件中进行配置ContextLoaderListener

SSH整合步骤

3.加入数据源

-加入jar:

mysql-connector-java-5.1.7-bin.jar

c3p0-0.9.1.2.jar

-在类目录下写配置属性文件:db.properties

jdbc.driver=com.mysql.jdbc.Driver

jdbc.url=jdbc:mysql://localhost:3306/bookstore1

jdbc.username=root

jdbc.password=root

-在application.xml文件中进行配置数据源

SSH整合步骤

-创建数据库sshdome

4.整合hibernate

-加入jar:

hibernate-commons-annotations-4.0.2.Final.jar

hibernate-core-4.2.4.Final.jar

hibernate-jpa-2.0-api-1.0.1.Final.jar

javassist-3.15.0-GA.jar

jboss-logging-3.1.0.GA.jar

jboss-transaction-api_1.1_spec-1.0.1.Final.jar

dom4j-1.6.1.jar

-在类目录下写hibernate配置文件

SSH整合步骤

-写entity类及entity映射文件

SSH整合步骤

-在application.xml文件中进行配置SessionFactory

SSH整合步骤

5.写dao层,如:UserDao

6.写service层,如UserService

7.整合struts

-加入jar:

antlr-2.7.7.jar

asm-3.3.jar

asm-commons-3.3.jar

asm-tree-3.3.jar

struts2-core-2.3.15.3.jar

struts2-spring-plugin-2.3.15.3.jar

xwork-core-2.3.15.3.jar

ognl-3.0.6.jar

commons-lang3-3.1.jar

commons-fileupload-1.3.jar

commons-io-2.0.1.jar

freemarker-2.3.19.jar

-在web.xml文件中进行配置StrutsPrepareAndExecuteFilter

<filter>

<filter-name>StrutsPrepareAndExecuteFilter</filter-name>

<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>

</filter>

<filter-mapping>

<filter-name>StrutsPrepareAndExecuteFilter</filter-name>

<url-pattern>/*</url-pattern>

</filter-mapping>

-在类目录下写配置文件struts.xml

SSH整合步骤

8.写单元测试题,创建IOC容器的同时,hibenater也会创建entity对应的表

大数据培训