struts2.1.8 + spring2.5.6 + hibernate3.3.2 integration of the landing zone jar package

2010-03-22  来源:本站原创  分类:Java  人气:575 

The integrated version is: struts2.1.8 + spring2.5.6 + hibernate3.3.2

http://www.javaeye.com/topic/531396

1. The first integration of hibernate and spring:

================================================== ==========

hibernate required jar package:

antlr-2.7.6.jar, commons-collections-3.1.jar, dom4j-1.6.1.jar, hibernate3.jar, javassist-3.9.0.GA.jar, jta-1.1.jar, slf4j-api-1.5. 8.jar, log4j.jar, slf4j-log4j12-1.5.8.jar (slf4j interfaces implemented as log4j), because the way it uses annotations needed (annotation3.4 package): ejb3-persistence.jar, hibernate -annotations.jar, hibernate-commons-annotations.jar, hibernate-entitymanager.jar, hibernate-validator.jar, jboss-archive-browsing.jar, using c3p0 connection pooling, but also: c3p0-0.9.1.2.jar

================================================== ======================

spring required jar package: spring.jar, commons-logging.jar, spring annotation needs: common-annotations.jar, aop need: aspectjrt.jar, aspectjweaver.jar, cglib-nodep-2.1_3.jar

hibernate.cfg.xml configuration:

1. <? Xml version = '1 .0 'encoding =' UTF-8 '?>
2. <! DOCTYPE hibernate-configuration PUBLIC
3. "- / / Hibernate / Hibernate Configuration DTD 3.0 / / EN"
4. "Http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
5.
6. <hibernate-configuration>
7.
8. <session-factory>
9. <property Name="dialect">
10. Org.hibernate.dialect.MySQLDialect
11. </ Property>
12. <property Name="connection.url">
13. Jdbc: mysql: / / localhost: 3306/oa
14. </ Property>
15. <property Name="connection.username"> root </ property>
16. <property Name="connection.password"> root </ property>
17. <property Name="connection.driver_class">
18. Com.mysql.jdbc.Driver
19. </ Property>
20. <property Name="myeclipse.connection.profile"> mysql5 </ property>
21. <property Name="show_sql"> true </ property>
22. <property Name="current_session_context_class"> thread </ property>
23. <property Name="hbm2ddl.auto"> update </ property>
24.
25. "! - First of all to say that I use the c3p0 connection pool the way -"
26. <property Name="connection.provider_class">
27. Org.hibernate.connection.C3P0ConnectionProvider
28. </ Property>
29. "! - Maximum number of connections -"
30. <property Name="hibernate.c3p0.max_size"> 20 </ property>
31. "! - The minimum number of connections -"
32. <property Name="hibernate.c3p0.min_size"> 2 </ property>
33. "! - Get the connection timeout time, if more than this time, will throw an exception, in milliseconds -"
34. <property Name="hibernate.c3p0.timeout"> 5000 </ property>
35. "! - The largest number of PreparedStatement -"
36. <property Name="hibernate.c3p0.max_statements"> 100 </ property>
37. "! - Check the connection pool every 1000 seconds of idle connections, units of seconds -"
38. <property Name="hibernate.c3p0.idle_test_period"> 1000 </ property>
39. "! - When the connection pooling the connection inside the time run out, C3P0 Get a new look at the number of connections -"
40. <property Name="hibernate.c3p0.acquire_increment"> 2 </ property>
41. "! - Always verify the connection is available -"
42. <property Name="hibernate.c3p0.validate"> true </ property>
43.
44. <mapping />
45.
46. </ Session-factory>
47.
48. </ Hibernate-configuration>

================================================== ========
applicationContext.xml configuration is as follows:

1. <? Xml version = "1.0" encoding = "UTF-8"?>
2. <Beans xmlns = "http://www.springframework.org/schema/beans"
3. Xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns: context = "http://www.springframework.org/schema/context"
4. Xmlns: aop = "http://www.springframework.org/schema/aop" xmlns: tx = "http://www.springframework.org/schema/tx"
5. Xsi: schemaLocation = "http://www.springframework.org/schema/beans
6. Http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
7. Http://www.springframework.org/schema/context
8. Http://www.springframework.org/schema/context/spring-context-2.5.xsd
9. Http://www.springframework.org/schema/aop
10. Http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
11. Http://www.springframework.org/schema/tx
12. Http://www.springframework.org/schema/tx/spring-tx-2.5.xsd ">
13.
14. <context:component-scan Base-package="com.fsj" /> <! - To enable automatic scanning - "
15. "! - Based on hibernate annotation sessionFactory ->
16. <Bean
17. "
18. <property Name="configLocation" value="classpath:hibernate.cfg.xml">
19. </ Property>
20. </ Bean>
21. "! - Based on hibernate transaction manager -"
22. <bean>
23. <property Name="sessionFactory" ref="sessionFactory" />
24. </ Bean>
25. "! - Use of annotations form of declarative transaction management -"
26. <tx:annotation-driven Transaction-manager="txManager"/>
27.
28. </ Beans>

================================================== ======================
Then add struts2:

Add Package: xwork-core-2.1.6.jar, struts2-core-2.1.8.jar, ognl-2.7.3.jar, freemarker-2.3.15.jar, commons-io-1.3.2.jar, commons -fileupload-1.2.1.jar, struts2-spring-plugin-2.1.8.jar

web.xml the following settings:

1. <? Xml version = "1.0" encoding = "UTF-8"?>
2. <Web-app version = "2.5"
3. Xmlns = "http://java.sun.com/xml/ns/javaee"
4. Xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"
5. Xsi: schemaLocation = "http://java.sun.com/xml/ns/javaee
6. Http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd ">
7.
8. <context-param>
9. <param-name> ContextConfigLocation </ param-name>
10. <param-value> Classpath: applicationContext.xml </ param-value>
11. </ Context-param>
12.
13. <listener>
14. <listener-class> Org.springframework.web.context.ContextLoaderListener </ listener-class>
15. </ Listener>
16.
<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>
25.
26. <filter>
27. <filter-name> Encoding </ filter-name>
28. <filter-class> Org.springframework.web.filter.CharacterEncodingFilter </ filter-class>
29. <init-param>
30. <param-name> Encoding </ param-name>
31. <param-value> UTF-8 </ param-value>
32. </ Init-param>
33. </ Filter>
34. <filter-mapping>
35. <filter-name> Encoding </ filter-name>
36. <url-pattern> / * </ Url-pattern>
37. </ Filter-mapping>
38.
39.
40. <filter>
41. <filter-name> OpenSessionInViewFilter </ filter-name>
42. <filter-class> Org.springframework.orm.hibernate3.support.OpenSessionInViewFilter </ filter-class>
43. </ Filter>
44. <filter-mapping>
45. <filter-name> OpenSessionInViewFilter </ filter-name>
46. <url-pattern> / * </ Url-pattern>
47. </ Filter-mapping>
48.
49. </ Web-app>

struts.xml are as follows:

1. <? Xml version = "1.0" encoding = "UTF-8"?>
2. <! DOCTYPE struts PUBLIC
3. "- / / Apache Software Foundation / / DTD Struts Configuration 2.0 / / EN"
4. "Http://struts.apache.org/dtds/struts-2.0.dtd">
5.
6. <struts>
7.
8. "! - The specified default encoding set of Web applications, is equivalent to calling the setCharacterEncoding method of HttpServletRequest -"
9. <constant Name="struts.i18n.encoding" value="UTF-8" />
10. "! - Set the browser cache static content, the default value is true (to use the production environment), development stage, turn off the -"
11. <constant Name="struts.serve.static.browserCache" value="false" />
12. "! - When the struts configuration file changes, the system is automatically re-load the file, the default value is false (to use the production environment), the development phase is best to open -"
13. <constant Name="struts.configuration.xml.reload" value="true" />
14. "! - Development model to use, so you can print out a more detailed error messages -"
15. <constant Name="struts.devMode" value="true" />
16. "! - The default view of the theme -"
17. <constant Name="struts.ui.theme" value="simple" />
18. "! - To spring into action to create an object -"
19. <constant Name="struts.objectFactory" value="spring" />
20.
21. <package Name="myDefault" extends="struts-default">
22. <default-action-ref Name="indexPage" />
23. <global-results>
24. <result Name="exceptionPage"> / WEB-INF/exceptionPage.jsp
25. </ Result>
26. </ Global-results>
27. <global-exception-mappings>
28. <exception-mapping Result="exceptionPage" exception="java.lang.Exception" />
29. </ Global-exception-mappings>
30. <action Name="indexPage">
31. <result> / Login.jsp </ result>
32. </ Action>
33. </ Package>
34.
35. <package Name="user" namespace="/user" extends="myDefault">
36. "! - This inside the class was not referring to the full class path, it means that in spring defined bean name of the -"
37. <action Name="*UserAction" method="{1}">
38. <result Name="success"> / WEB-INF/user/loginSuccess.jsp </ result>
39. <result Name="input"> / login.jsp </ result>
40. </ Action>
41. </ Package>
42.
43. </ Struts>

=======================================
************************************************** ********************
The technology used: spring2.0 + struts2.0 + hibernate3.0
spring2.0 the JAR packages:
1, spring-2.0.jar,
Struts2.0 the JAR packages:
1, struts2-core-2.0.11.1.jar;
2, struts2-spring-plugin-2.0.11.1.jar;
3, xwork-2.0.4.jar;
4, ognl-2.6.11.jar
5, freemarker-2.3.8.jar
hibernate3.0 the JAR packages:
1, hibernate3.jar
2, hibernate-annotations.jar
3, antlr-2.7.6.jar;
4, cglib-nodep-2.1_3.jar
5, commons-beanutils-1.7.0.jar

In addition: Connection database 2 Jar Package:
1, commons-dbcp.jar;
2, commons-pool.jar

Make matters Jar package:
1, jta.jar;
Parsing XML file:
1.dom4j.xml

================================================== ==================
************************************************** ********************************************
ssh: Struts1.2 + Hibernate3.2 + Spring2.0

antlr-2.7.6rc1.jar
asm.jar
asm-attrs.jar
cglib-2.1.3.jar
commons-attributes-api.jar
commons-beanutils.jar
commons-codec.jar
commons-collections-2.1.1.jar
commons-dbcp.jar
commons-digester.jar
commons-discovery.jar
commons-fileupload.jar
commons-httpclient.jar
commons-io.jar
commons-lang.jar
commons-logging-1.0.4.jar
commons-pool.jar
commons-validator.jar
dom4j-1.6.1.jar
ehcache-1.1.jar
hibernate3.jar
jaas.jar
jaxen-1.1-beta-7.jar
jdbc2_0-stdext.jar
jstl.jar
jta.jar
junit-4.1.jar
log4j-1.2.11.jar
mysql-connector-java-5.1.7-bin.jar
spring.jar
spring-webmvc-struts.jar
standard.jar
struts.jar
xerces-2.6.2.jar
xml-apis.jar

相关文章