http://www.cnblogs.com/piahb605/archive/2011/12/25/2301091.html
1.安裝java環境,jdk1.7.0_01,配置環境變量及JAVA_HOME.
2.環境準備Myeclipse? 9,通過fq下載后破解(具體破解方法可以在網上搜索)。
Tomcat配置環境變量。3.安裝tomcat-6.0.35.
環境準備好后,打開Myeclipse,window-Preferences-myeclipse
配置tomcat環境。
eclipse tomcat配置。4.新建項目,選擇webproject.
5.copy struts jar包到WebRoot-WEB-INF-lib.我加的jar包如下。
6.增加spring,選中項目后點擊Myeclipse-Project Capabilities-Add Spring Capabilities.選擇
myeclipse環境變量配置,Spring 3.0 Core Library
Spring 3.0 persistence? Core Library
Spring 3.0 AOP Library
Spring 3.0 Web Library
java netty框架、
增加至lib目錄下,點擊下一步,取消Enable AOP Builder,點擊Finish。完成后增加struts2-spring-plugin-2.2.3.jar到lib目錄。
7.增加Hibernate ,選中項目后點擊Myeclipse-Project Capabilities-Add?Hibernate Capabilities.選擇(默認先擇就好)
java中ssh框架?接著如下圖
下一步,在頁面選擇Existing Spring configuration file ,點擊下一步頁面,配置數據庫連接,點擊finish.
8.copy struts.xml文件到src目錄下,內容如下:
myeclipse配置java?<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
??<constant name="struts.devMode" value="true" />
?<package name="sshdemo3" extends="struts-default">
?
?</package>
</struts>
myeclipse項目配置jdk,9.配置web.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
?xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
?xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
?http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
?<display-name>First SSH Project</display-name>
?<filter>
??<filter-name>struts2</filter-name>
??<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
?</filter>
?<filter-mapping>
??<filter-name>struts2</filter-name>
??<url-pattern>/*</url-pattern>
?</filter-mapping>
?<!-- 配置spring的監聽器 -->
?<listener>
??<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
?</listener>
?<welcome-file-list>
??<welcome-file>index.jsp</welcome-file>
?</welcome-file-list>
</web-app>
10.配置applicationContext.xml文件,
?
java ssh、<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
?xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
?xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
?<bean id="dataSource"
??class="org.apache.commons.dbcp.BasicDataSource">
??<property name="driverClassName"
???value="com.mysql.jdbc.Driver">??
??</property>
??<property name="url" value="jdbc:mysql://localhost:3306/test"></property>
??<property name="username" value="root"></property>
??<property name="password" value="gzcss"></property>
?</bean>
?<bean id="sessionFactory"
??class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
??<property name="dataSource">
???<ref bean="dataSource" />
??</property>
??<property name="hibernateProperties">
???<props>
????<prop key="hibernate.dialect">
?????org.hibernate.dialect.MySQLDialect
????</prop>
????<prop key="hibernate_show">true</prop>
???</props>
??</property>
??<property name="mappingResources">
???<list>
????<value>com/ssh/model/Customer.hbm.xml</value>
???</list>
??</property>
?</bean>
?<bean id="customerDao" class="com.ssh.dao.impl.CustomerDao">
?<property name="sessionFactory">
?<ref bean="sessionFactory"/>
?</property>
?</bean>
?<bean id="CustomerserviceBo" class="com.ssh.bo.impl.CustomerService">
?<property name="customerDao" >
??<ref bean="customerDao"/>
?</property>
?</bean>
?<bean name="customerListBean" class="com.ssh.user.action.UserAction" scope="prototype">
??<property name="customerservice" ref="CustomerserviceBo"></property>
?</bean>
?</beans>
11.需要另外copy如下jar包到lib目錄下。
commons-dbcp-1.4.jar
java ssh連接、commons-pool-1.5.6.jar
12.注意事項,hibernate映射文件一定要配置正確,很重要。否則會報錯。如下:
Customer.hbm.xml
?
java netty。<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Mapping file autogenerated by MyEclipse Persistence Tools -->
<hibernate-mapping>
?<class name="com.ssh.model.Customer" table="customer" >
? <id name="customerid" type="java.lang.Integer">
??????????? <column name="CustomerId" />
??????????? <generator class="native" />
??????? </id>
??
??<property name="customername" column="CustomerName" type="java.lang.String"></property>
?</class>
</hibernate-mapping>
?
以上基本配置完成,如大家碰到問題可以一起討論。