SSH项目整合开发的环境搭建

来源:互联网 发布:淘宝童装店铺排名 编辑:程序博客网 时间:2024/05/01 01:11


SSH项目整合开发的环境搭建


spring jar下载地址


http://maven.springframework.org/release/org/springframework/spring/


环境搭建是一个难点


通用包(7个):
commons-dbcp2-2.1.jar
commons-logging-1.1.3.jar
commons-pool2-2.3.jar
commons-collections4-4.0.jar
aopalliance-1.0-20100517.210215-13.jar
mysql-connector-java-5.1.33-bin.jar
aspectjweaver-1.6.9.jar


struts包(13+1)
asm-3.3.jar
asm-commons-3.3.jar
asm-tree-3.3.jar
commons-fileupload-1.3.1.jar
commons-io-2.2.jar
commons-lang3-3.2.jar
freemarker-2.3.22.jar
javassist-3.11.0.GA.jar
log4j-api-2.2.jar
log4j-core-2.2.jar
ognl-3.0.6.jar
struts2-core-2.3.24.jar
xwork-core-2.3.24.jar


struts2-spring-plugin-2.3.24.jar




hibernate包(10个)


antlr-2.7.7.jar
dom4j-1.6.1.jar
hibernate-commons-annotations-4.0.5.Final.jar
hibernate-core-4.3.10.Final.jar
hibernate-jpa-2.1-api-1.0.0.Final.jar
jandex-1.1.0.Final.jar
javassist-3.18.1-GA.jar
jboss-logging-3.1.3.GA.jar
jboss-logging-annotations-1.2.0.Beta1.jar
jboss-transaction-api_1.2_spec-1.0.0.Final.jar


spring包(10个)
spring-beans-4.1.6.RELEASE.jar
spring-context-4.1.6.RELEASE.jar
spring-core-4.1.6.RELEASE.jar
spring-expression-4.1.6.RELEASE.jar
spring-aop-4.1.6.RELEASE.jar
spring-web-4.1.6.RELEASE.jar
spring-orm-4.1.6.RELEASE.jar
spring-tx-4.1.6.RELEASE.jar
spring-jdbc-4.1.6.RELEASE.jar
spring-aspects-4.1.6.RELEASE.jar


整合包下载(包含Jar包和配置文件)


http://pan.baidu.com/s/1bn54wd5


SSH环境配置
1.配置jar包
2.增加配置文件

  (1) web.xml


<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">


    <display-name>Struts Blank</display-name>


    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>


    <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>


    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
    </welcome-file-list>


</web-app>




  (2) struts.xml


<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">


<struts>
    <package name="all" namespace="/" extends="struts-default">
    </package>
</struts>


 (3) hibernate-cfg.xml


<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">


<hibernate-configuration>
<session-factory>
      <!-- Database connection settings -->
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/album</property> 
<property name="connection.username">root</property>   ///这里面的密码和用户名等等以及数据库都是和自己的数据库有关
<property name="connection.password">12345678</property>  
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">true</property>
        <!-- Drop and re-create the database schema on startup -->
        <property name="hbm2ddl.auto">update</property>
        <mapping class="net.xinqushi.model.User"/>
</session-factory>
</hibernate-configuration>


 (4)applicationContext.xml


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd">


</beans>


struts.xml和 hibernate-cfg.xml放在src目录下
applicationContext.xml和web.xml放在 WEB-INF目录下




原创粉丝点击