{"id":1633,"date":"2018-05-30T20:35:55","date_gmt":"2018-05-30T12:35:55","guid":{"rendered":"http:\/\/www.netxintai.com\/?p=1633"},"modified":"2018-06-19T16:51:20","modified_gmt":"2018-06-19T08:51:20","slug":"struts2-spring4-hibernate5%ef%bc%88s2sh%ef%bc%89%e6%95%b4%e5%90%88%e5%bc%80%e5%8f%91-%e9%a1%b9%e7%9b%ae%e6%95%b4%e4%bd%93%e6%9e%b6%e6%9e%84%e7%9a%84%e6%90%ad%e5%bb%ba","status":"publish","type":"post","link":"https:\/\/www.netxintai.com\/?p=1633","title":{"rendered":"S2SH\u6574\u5408\u5f00\u53d1&#8211;\u9879\u76ee\u6574\u4f53\u67b6\u6784\u4e4b\u57fa\u672c\u914d\u7f6e"},"content":{"rendered":"<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u672c\u5f00\u53d1\u9879\u76ee\u5f00\u53d1\u7528\u5230\u7684\u6846\u67b6\u7248\u672c:struts-2.3.24\u3001spring-4.2.4\u3001hibernate5.0.7\u3002\u6570\u636e\u5e93\uff1amySQL\u3002\u4e5f\u5c31\u662f\u6211\u4eec\u4fd7\u79f0\u7684S2SH\u4e09\u5927\u6846\u67b6\u6574\u5408\u5f00\u53d1\u3002\u533a\u522b\u4e8eSSH\u5f00\u53d1\u6240\u7528\u5230\u7684\u6846\u67b6\u5219\u662fspring springmvc hibernate\u4e09\u5927\u6846\u67b6.<\/p>\n<p><span style=\"color: rgb(79, 79, 79); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; font-size: 18px; text-align: justify; background-color: rgb(255, 255, 255);\"><img decoding=\"async\" src=\"\/ueditor\/php\/upload\/image\/20180531\/1527731797385927.png\" title=\"1527731797385927.png\" alt=\"image.png\"\/><\/span><\/p>\n<p style=\"text-align: justify; \">&nbsp; &nbsp; &nbsp; &nbsp;\u6846\u67b6\u6240\u7528\u5230\u7684jar\u5305\u6211\u4f1a\u4e0a\u4f20\u5230\u767e\u5ea6\u4e91\u514d\u8d39\u5927\u5bb6\u4e0b\u8f7d\uff1a<a href=\"https:\/\/pan.baidu.com\/s\/1wXp9gsBDlHiGnwCIQiTDhA\">\u5ea6\u76d8\u94fe\u63a5<\/a><\/p>\n<p style=\"text-align: justify; \">&nbsp; &nbsp; &nbsp; &nbsp;\u767e\u5ea6\u4e91\u76d8: https:\/\/pan.baidu.com\/s\/1wXp9gsBDlHiGnwCIQiTDhA<\/p>\n<p style=\"text-align: justify; \">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u95f2\u8bdd\u5c11\u804a\uff0c\u76f4\u63a5\u4e0a\u56fe\uff0c\u672c\u6559\u7a0b\u9002\u7528\u4e8e\u6709\u4e09\u5927\u6846\u67b6\u57fa\u7840\u4eba\u5458\u4f7f\u7528\u3002<\/p>\n<p style=\"text-align: justify; \">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u9996\u5148\u662fweb.xml\u914d\u7f6e<\/p>\n<pre class=\"brush:xml;toolbar:false;\">&lt;?xml&nbsp;version=&quot;1.0&quot;&nbsp;encoding=&quot;UTF-8&quot;?&gt;\r\n&lt;web-app&nbsp;xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot;&nbsp;xmlns=&quot;http:\/\/java.sun.com\/xml\/ns\/javaee&quot;&nbsp;xsi:schemaLocation=&quot;http:\/\/java.sun.com\/xml\/ns\/javaee&nbsp;http:\/\/java.sun.com\/xml\/ns\/javaee\/web-app_2_5.xsd&quot;&nbsp;id=&quot;WebApp_ID&quot;&nbsp;version=&quot;2.5&quot;&gt;\r\n&nbsp;&nbsp;&lt;display-name&gt;netxintai&lt;\/display-name&gt;\r\n&nbsp;&nbsp;\r\n&nbsp;&nbsp;&lt;!--&nbsp;\u914d\u7f6estruts2\u62e6\u622a\u5668--&gt;\r\n&nbsp;&nbsp;&lt;filter&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;filter-name&gt;struts2&lt;\/filter-name&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;filter-class&gt;org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter&lt;\/filter-class&gt;\r\n&nbsp;&nbsp;&lt;\/filter&gt;\r\n&nbsp;&nbsp;&lt;filter-mapping&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;filter-name&gt;struts2&lt;\/filter-name&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;url-pattern&gt;\/*&lt;\/url-pattern&gt;\r\n&nbsp;&nbsp;&lt;\/filter-mapping&gt;\r\n&nbsp;&nbsp;\r\n&nbsp;&nbsp;&lt;!--&nbsp;\u914d\u7f6espring\u76d1\u542c\u5668--&gt;\r\n&nbsp;&nbsp;&lt;listener&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;\/listener-class&gt;\r\n&nbsp;&nbsp;&lt;\/listener&gt;\r\n&nbsp;&nbsp;&lt;context-param&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;param-name&gt;contextConfigLocation&lt;\/param-name&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;param-value&gt;classpath:beans.xml&lt;\/param-value&gt;\r\n&nbsp;&nbsp;&lt;\/context-param&gt;\r\n&nbsp;&nbsp;\r\n&nbsp;&nbsp;&lt;welcome-file-list&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;welcome-file&gt;index.html&lt;\/welcome-file&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;welcome-file&gt;index.htm&lt;\/welcome-file&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;welcome-file&gt;index.jsp&lt;\/welcome-file&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;welcome-file&gt;default.html&lt;\/welcome-file&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;welcome-file&gt;default.htm&lt;\/welcome-file&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;welcome-file&gt;default.jsp&lt;\/welcome-file&gt;\r\n&nbsp;&nbsp;&lt;\/welcome-file-list&gt;\r\n\r\n&lt;\/web-app&gt;<\/pre>\n<p>&nbsp;spring.xml \u6574\u5408\u540e\u7684Spring.xml\u53ef\u4ee5\u968f\u610f\u5b9a\u4e49\u540d\u5b57\u6211\u8fd9\u91cc\u53d6\u7684\u540d\u5b57bean.xml.<\/p>\n<pre class=\"brush:xml;toolbar:false\">&lt;?xml&nbsp;version=&quot;1.0&quot;&nbsp;encoding=&quot;UTF-8&quot;?&gt;\r\n&lt;beans&nbsp;xmlns=&quot;http:\/\/www.springframework.org\/schema\/beans&quot;\r\n\txmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot;&nbsp;xmlns:context=&quot;http:\/\/www.springframework.org\/schema\/context&quot;\r\n\txmlns:aop=&quot;http:\/\/www.springframework.org\/schema\/aop&quot;&nbsp;xmlns:tx=&quot;http:\/\/www.springframework.org\/schema\/tx&quot;\r\n\txsi:schemaLocation=&quot;http:\/\/www.springframework.org\/schema\/beans\r\n\thttp:\/\/www.springframework.org\/schema\/beans\/spring-beans.xsd\r\n\thttp:\/\/www.springframework.org\/schema\/context\r\n\thttp:\/\/www.springframework.org\/schema\/context\/spring-context.xsd\r\n\thttp:\/\/www.springframework.org\/schema\/aop\r\n\thttp:\/\/www.springframework.org\/schema\/aop\/spring-aop.xsd\r\n\thttp:\/\/www.springframework.org\/schema\/tx\r\n\thttp:\/\/www.springframework.org\/schema\/tx\/spring-tx.xsd&quot;&gt;\r\n\r\n\t&lt;!--&nbsp;\u642d\u5efaspring\u57fa\u672c\u914d\u7f6e\u73af\u5883&nbsp;--&gt;\r\n\t&lt;!--&nbsp;\u914d\u7f6ec3p0\u8fde\u63a5\u6c60&nbsp;--&gt;\r\n\t&lt;bean&nbsp;id=&quot;dataSource&quot;&nbsp;class=&quot;com.mchange.v2.c3p0.ComboPooledDataSource&quot;&gt;\r\n\r\n\t\t&lt;property&nbsp;name=&quot;driverClass&quot;&nbsp;value=&quot;com.mysql.jdbc.Driver&quot;&gt;&lt;\/property&gt;\r\n\t\t&lt;property&nbsp;name=&quot;jdbcUrl&quot;&nbsp;value=&quot;jdbc:mysql:\/\/\/xintai&quot;&gt;&lt;\/property&gt;\r\n\t\t&lt;property&nbsp;name=&quot;user&quot;&nbsp;value=&quot;root&quot;&gt;&lt;\/property&gt;\r\n\t\t&lt;property&nbsp;name=&quot;password&quot;&nbsp;value=&quot;123&quot;&gt;&lt;\/property&gt;\r\n\t&lt;\/bean&gt;\r\n\r\n\t&lt;!--&nbsp;\u5f00\u542fHibernate\u4e2dsessionFacotry\u5de5\u5382&nbsp;--&gt;\r\n\t&lt;bean&nbsp;id=&quot;sessionFactory&quot;&nbsp;class=&quot;org.springframework.orm.hibernate5.LocalSessionFactoryBean&quot;&gt;\r\n\t\t&lt;property&nbsp;name=&quot;dataSource&quot;&nbsp;ref=&quot;dataSource&quot;&gt;&lt;\/property&gt;\r\n\t\t&lt;property&nbsp;name=&quot;configLocations&quot;&nbsp;value=&quot;classpath:hibernate.cfg.xml&quot;&gt;&lt;\/property&gt;\r\n\r\n\t&lt;\/bean&gt;\r\n\t&lt;!--&nbsp;\u5f00\u542f\u6570\u636e\u5e93\u64cd\u4f5c\u5bf9\u8c61hibernateTemple&nbsp;--&gt;\r\n\t&lt;bean&nbsp;id=&quot;hibernateTemplate&quot;&nbsp;class=&quot;org.springframework.orm.hibernate5.HibernateTemplate&quot;&gt;\r\n\t\t&lt;property&nbsp;name=&quot;sessionFactory&quot;&nbsp;ref=&quot;sessionFactory&quot;&gt;&lt;\/property&gt;\r\n\t&lt;\/bean&gt;\r\n\r\n\t&lt;!--&nbsp;\u5f00\u542f\u4e8b\u52a1&nbsp;--&gt;\r\n\t&lt;bean&nbsp;id=&quot;transactionManager&quot;&nbsp;class=&quot;org.springframework.orm.hibernate5.HibernateTransactionManager&quot;&gt;\r\n\t\t&lt;property&nbsp;name=&quot;sessionFactory&quot;&nbsp;ref=&quot;sessionFactory&quot;&gt;&lt;\/property&gt;\r\n\r\n\t&lt;\/bean&gt;\r\n\t&lt;!--&nbsp;\u914d\u7f6e\u4e8b\u52a1\u4f5c\u4ee5\u6ce8\u89e3\u7684\u5f62\u5f0f\u5b9e\u73b0&nbsp;--&gt;\r\n\t&lt;tx:annotation-driven&nbsp;transaction-manager=&quot;transactionManager&quot;&nbsp;\/&gt;\r\n\t\r\n\t&lt;!--&nbsp;\u5f00\u542f\u6ce8\u89e3\u626b\u63cf&nbsp;--&gt;\r\n&lt;context:component-scan&nbsp;base-package=&quot;com.netxintai&quot;&gt;&lt;\/context:component-scan&gt;\r\n\r\n\t&lt;!--&nbsp;\u5b9a\u4e49\u672c\u9879\u76ee\u4e2d\u7684bean&nbsp;--&gt;\r\n\r\n\t\r\n\t\r\n&lt;\/beans&gt;<\/pre>\n<p><span style=\"color: rgb(79, 79, 79); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; font-size: 18px; text-align: justify; background-color: rgb(255, 255, 255);\">Hibernate\u914d\u7f6e\u6587\u4ef6&nbsp;hibernate.cfg.xml \u53e6\u5916Hibernate\u6574\u5408\u540e\u53ef\u4ee5\u4e0d\u5b58\u5728\uff0c\u76f4\u63a5\u914d\u7f6e\u5728spring.xml\u4e2d\uff0c\u4f46\u662f\u4e3a\u4e86\u76f4\u89c2\u6211\u8fd8\u662f\u65b0\u5efa\u4e00\u4e2a\u3002<\/span><\/p>\n<pre class=\"brush:xml;toolbar:false\">&lt;!DOCTYPE&nbsp;hibernate-configuration&nbsp;PUBLIC&nbsp;&quot;-\/\/Hibernate\/Hibernate&nbsp;Configuration&nbsp;DTD&nbsp;3.0\/\/EN&quot;&nbsp;&quot;http:\/\/www.hibernate.org\/dtd\/hibernate-configuration-3.0.dtd&quot;&gt;\r\n&lt;hibernate-configuration&gt;\r\n\t&lt;session-factory&gt;\r\n\t\r\n\t&lt;!--&nbsp;\u81ea\u5b9a\u4e49mysql&nbsp;\u5c5e\u6027&nbsp;--&gt;\r\n\t\t&lt;property&nbsp;name=&quot;hibernate.dialect&quot;&gt;org.hibernate.dialect.MySQLDialect&lt;\/property&gt;\r\n\t\t&lt;property&nbsp;name=&quot;hibernate.show_sql&quot;&gt;true&lt;\/property&gt;\r\n\t\t&lt;property&nbsp;name=&quot;hibernate.format_sql&quot;&gt;true&lt;\/property&gt;\r\n\t\t&lt;property&nbsp;name=&quot;hibernate.hbm2ddl.auto&quot;&gt;update&lt;\/property&gt;\r\n\t\t\r\n\t&lt;!--&nbsp;\u6dfb\u52a0\u672c\u9879\u76ee\u81ea\u5b9a\u4e49\u7c7b&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--&gt;\r\n\t\r\n\t&nbsp;&nbsp;&nbsp;&nbsp;\r\n\t&nbsp;\r\n\t&lt;\/session-factory&gt;\r\n\t\r\n&lt;\/hibernate-configuration&gt;<\/pre>\n<p><span style=\"color: rgb(79, 79, 79); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; font-size: 18px; text-align: justify; background-color: rgb(255, 255, 255);\"><\/span>\u6700\u540e\u662fstrust\u7684\u914d\u7f6e\u6587\u4ef6<\/p>\n<pre class=\"brush:xml;toolbar:false\">&lt;?xml&nbsp;version=&quot;1.0&quot;&nbsp;encoding=&quot;UTF-8&quot;&nbsp;?&gt;\r\n&lt;!DOCTYPE&nbsp;struts&nbsp;PUBLIC\r\n&nbsp;&nbsp;&nbsp;&nbsp;&quot;-\/\/Apache&nbsp;Software&nbsp;Foundation\/\/DTD&nbsp;Struts&nbsp;Configuration&nbsp;2.0\/\/EN&quot;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&quot;http:\/\/struts.apache.org\/dtds\/struts-2.0.dtd&quot;&gt;\r\n\r\n\r\n&lt;struts&gt;\r\n\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;package&nbsp;name=&quot;default&quot;&nbsp;namespace=&quot;\/&quot;&nbsp;extends=&quot;struts-default&quot;&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;\t\r\n\r\n&nbsp;&nbsp;&nbsp;\t&lt;\/package&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;\r\n\r\n&lt;\/struts&gt;<\/pre>\n<p>\u81f3\u6b64\u6700\u57fa\u7840\u7684\u73af\u5883\u642d\u5efa\u5b8c\u6bd5\u3002\u7136\u540e\u5c31\u53ef\u4ee5\u6784\u67b6\u81ea\u5df1\u7684\u7cfb\u7edf\u4e86\u3002<span style=\"color: rgb(79, 79, 79); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; font-size: 18px; text-align: justify; background-color: rgb(255, 255, 255);\"><br \/><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u672c\u5f00\u53d1\u9879\u76ee\u5f00\u53d1 <span class=\"ellipsis\">&hellip;<\/span> <span class=\"more-link-wrap\"><a href=\"https:\/\/www.netxintai.com\/?p=1633\" class=\"more-link\"><span>Read More &rarr;<\/span><\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":1491,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[210],"tags":[163,162,164],"_links":{"self":[{"href":"https:\/\/www.netxintai.com\/index.php?rest_route=\/wp\/v2\/posts\/1633"}],"collection":[{"href":"https:\/\/www.netxintai.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.netxintai.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.netxintai.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.netxintai.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1633"}],"version-history":[{"count":10,"href":"https:\/\/www.netxintai.com\/index.php?rest_route=\/wp\/v2\/posts\/1633\/revisions"}],"predecessor-version":[{"id":1707,"href":"https:\/\/www.netxintai.com\/index.php?rest_route=\/wp\/v2\/posts\/1633\/revisions\/1707"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.netxintai.com\/index.php?rest_route=\/wp\/v2\/media\/1491"}],"wp:attachment":[{"href":"https:\/\/www.netxintai.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1633"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.netxintai.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1633"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.netxintai.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1633"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}