{"id":217391,"date":"2014-03-28T12:12:03","date_gmt":"2014-03-28T08:12:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=217391"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=217391","title":{"rendered":"<span class=\"post_title\">\u041b\u0435\u0433\u043a\u0438\u0439 \u0441\u0442\u0430\u0440\u0442: Spring + MongoDB<\/span>"},"content":{"rendered":"<div class=\"content html_format\"> \t\t\t<img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/6df\/7f2\/670\/6df7f2670123a6642cf9814bd41486de.png\"\/><\/p>\n<p>  \u041f\u043e\u0438\u0441\u043a\u0430\u043b \u043d\u0430 \u0445\u0430\u0431\u0440\u0435 \u0441\u0445\u043e\u0436\u0438\u0435 \u0441\u0442\u0430\u0442\u044c\u0438, \u043d\u0430\u0448\u0435\u043b \u0442\u043e\u043b\u044c\u043a\u043e <a href=\"http:\/\/habrahabr.ru\/post\/118783\/\">Morphia \u2014 \u043b\u0435\u0433\u043a\u0438\u0439 ORM \u0434\u043b\u044f MongoDB, \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0439 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f\u043c\u0438<\/a>, \u043d\u0438\u0447\u0435\u0433\u043e \u043f\u043e \u0441\u0432\u044f\u0437\u043a\u0435 Spring Data + MongoDB \u043d\u0435 \u043d\u0430\u0448\u043b\u043e\u0441\u044c, \u0432 \u0441\u0432\u044f\u0437\u0438 \u0441 \u044d\u0442\u0438\u043c \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u043e\u0441\u0442 \u0438\u0437 \u0440\u0430\u0437\u0434\u0435\u043b\u0430 \u00ab\u0434\u043b\u044f \u0441\u0430\u043c\u044b\u0445 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0445\u00bb \u043f\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e \u0441\u0432\u044f\u0437\u043a\u0438 Spring + MongoDB.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h5><b>\u0427\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0437 \u0441\u0435\u0431\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u0430\u043c\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435:<\/b><\/h5>\n<p> \u0421\u0434\u0435\u043b\u0430\u0435\u043c \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u043e\u0432, \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0440\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 CRUD.<\/p>\n<h5><b>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:<\/b><\/h5>\n<ul>\n<li>Spring IoC, MVC, Data (Mongo)<\/li>\n<li>Mongo Driver<\/li>\n<li>Log4j \u0447\u0435\u0440\u0435\u0437 sl4j<\/li>\n<li>\u043d\u0443 \u0438 \u043d\u0435\u043c\u043d\u043e\u0436\u043a\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043f\u0438\u0448\u0443 \u0443\u0436\u0435 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435<\/li>\n<\/ul>\n<p>  \u0421\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u0431\u0443\u0434\u0435\u0442 Maven, \u0430 \u043a\u043e\u0434, \u043b\u0438\u0447\u043d\u043e \u044f, \u043f\u0438\u0448\u0443 \u0432 Intellij IDEA (\u0434\u0443\u043c\u0430\u044e, \u044d\u0442\u043e \u043b\u0443\u0447\u0448\u0430\u044f IDE \u0434\u043b\u044f Java). \u041a\u0441\u0442\u0430\u0442\u0438 \u0433\u043e\u0432\u043e\u0440\u044f, \u043e \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430\u0445 \u044d\u0442\u043e\u0439 \u0441\u0440\u0435\u0434\u044b \u0432 \u0441\u0432\u043e\u0451 \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b <a href=\"http:\/\/habrahabr.ru\/users\/asolntsev\/\" class=\"user_link\">asolntsev<\/a> \u0432 \u043f\u043e\u0441\u0442\u0435 <a href=\"http:\/\/habrahabr.ru\/post\/112749\/\">\u041f\u043e\u0447\u0435\u043c\u0443 IDEA \u043b\u0443\u0447\u0448\u0435 Eclipse<\/a>.<\/p>\n<h5><b>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/b><\/h5>\n<p>  <b>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u043f\u0438\u0448\u0435\u043c pom.xml:<\/b><\/p>\n<pre><code class=\"xml\">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt; &lt;project xmlns=&quot;http:\/\/maven.apache.org\/POM\/4.0.0&quot;          xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot;          xsi:schemaLocation=&quot;http:\/\/maven.apache.org\/POM\/4.0.0 http:\/\/maven.apache.org\/xsd\/maven-4.0.0.xsd&quot;&gt;     &lt;modelVersion&gt;4.0.0&lt;\/modelVersion&gt;     &lt;packaging&gt;war&lt;\/packaging&gt;      &lt;groupId&gt;habra&lt;\/groupId&gt;     &lt;artifactId&gt;habr&lt;\/artifactId&gt;     &lt;version&gt;1.0-SNAPSHOT&lt;\/version&gt;      &lt;!-- \u041d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u044c\u0438, \u0432\u0435\u0440\u0441\u0438\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c\u0438 --&gt;     &lt;properties&gt;         &lt;project.build.sourceEncoding&gt;UTF-8&lt;\/project.build.sourceEncoding&gt;         &lt;version.jdk&gt;1.6&lt;\/version.jdk&gt;         &lt;version.spring&gt;4.0.2.RELEASE&lt;\/version.spring&gt;         &lt;version.spring.mongodb&gt;1.4.0.RELEASE&lt;\/version.spring.mongodb&gt;         &lt;version.jackson&gt;1.9.13&lt;\/version.jackson&gt;     &lt;\/properties&gt;      &lt;dependencies&gt;         &lt;!-- \u0412\u0441\u0435, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f Spring --&gt;         &lt;dependency&gt;             &lt;groupId&gt;org.springframework&lt;\/groupId&gt;             &lt;artifactId&gt;spring-core&lt;\/artifactId&gt;             &lt;version&gt;${version.spring}&lt;\/version&gt;         &lt;\/dependency&gt;          &lt;dependency&gt;             &lt;groupId&gt;org.springframework&lt;\/groupId&gt;             &lt;artifactId&gt;spring-web&lt;\/artifactId&gt;             &lt;version&gt;${version.spring}&lt;\/version&gt;         &lt;\/dependency&gt;          &lt;dependency&gt;             &lt;groupId&gt;org.springframework&lt;\/groupId&gt;             &lt;artifactId&gt;spring-webmvc&lt;\/artifactId&gt;             &lt;version&gt;${version.spring}&lt;\/version&gt;         &lt;\/dependency&gt;          &lt;dependency&gt;             &lt;groupId&gt;org.springframework&lt;\/groupId&gt;             &lt;artifactId&gt;spring-context&lt;\/artifactId&gt;             &lt;version&gt;${version.spring}&lt;\/version&gt;         &lt;\/dependency&gt;          &lt;dependency&gt;             &lt;groupId&gt;org.springframework.data&lt;\/groupId&gt;             &lt;artifactId&gt;spring-data-mongodb&lt;\/artifactId&gt;             &lt;version&gt;${version.spring.mongodb}&lt;\/version&gt;         &lt;\/dependency&gt;          &lt;!-- MongoDB \u0434\u0440\u0430\u0439\u0432\u0435\u0440 --&gt;         &lt;dependency&gt;             &lt;groupId&gt;org.mongodb&lt;\/groupId&gt;             &lt;artifactId&gt;mongo-java-driver&lt;\/artifactId&gt;             &lt;version&gt;2.11.4&lt;\/version&gt;         &lt;\/dependency&gt;          &lt;!--         Jackson JSON Mapper         \u0422\u0430\u0449\u0443 \u0435\u0433\u043e \u0432\u0441\u0435\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c API \u043d\u0430 \u0431\u0430\u0437\u0435 JSON \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432.         \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u044d\u0442\u0443 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u043d\u0435 \u0442\u044f\u043d\u0443\u0442\u044c.         --&gt;         &lt;dependency&gt;             &lt;groupId&gt;org.codehaus.jackson&lt;\/groupId&gt;             &lt;artifactId&gt;jackson-mapper-asl&lt;\/artifactId&gt;             &lt;version&gt;${version.jackson}&lt;\/version&gt;         &lt;\/dependency&gt;          &lt;!-- Servlet Api --&gt;         &lt;dependency&gt;             &lt;groupId&gt;javax.servlet&lt;\/groupId&gt;             &lt;artifactId&gt;servlet-api&lt;\/artifactId&gt;             &lt;version&gt;2.5&lt;\/version&gt;             &lt;scope&gt;provided&lt;\/scope&gt;         &lt;\/dependency&gt;          &lt;dependency&gt;             &lt;groupId&gt;javax.servlet.jsp&lt;\/groupId&gt;             &lt;artifactId&gt;jsp-api&lt;\/artifactId&gt;             &lt;version&gt;2.1&lt;\/version&gt;             &lt;scope&gt;provided&lt;\/scope&gt;         &lt;\/dependency&gt;          &lt;dependency&gt;             &lt;groupId&gt;jstl&lt;\/groupId&gt;             &lt;artifactId&gt;jstl&lt;\/artifactId&gt;             &lt;version&gt;1.2&lt;\/version&gt;         &lt;\/dependency&gt;          &lt;!-- \u041b\u043e\u0433\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 --&gt;         &lt;dependency&gt;             &lt;groupId&gt;log4j&lt;\/groupId&gt;             &lt;artifactId&gt;log4j&lt;\/artifactId&gt;             &lt;version&gt;1.2.17&lt;\/version&gt;         &lt;\/dependency&gt;          &lt;dependency&gt;             &lt;groupId&gt;org.slf4j&lt;\/groupId&gt;             &lt;artifactId&gt;slf4j-api&lt;\/artifactId&gt;             &lt;version&gt;1.7.5&lt;\/version&gt;         &lt;\/dependency&gt;          &lt;dependency&gt;             &lt;groupId&gt;org.slf4j&lt;\/groupId&gt;             &lt;artifactId&gt;slf4j-log4j12&lt;\/artifactId&gt;             &lt;version&gt;1.7.5&lt;\/version&gt;         &lt;\/dependency&gt;          &lt;!-- TEST --&gt;         &lt;dependency&gt;             &lt;groupId&gt;junit&lt;\/groupId&gt;             &lt;artifactId&gt;junit&lt;\/artifactId&gt;             &lt;version&gt;4.11&lt;\/version&gt;             &lt;scope&gt;test&lt;\/scope&gt;         &lt;\/dependency&gt;          &lt;!--         Apache Commons, \u0442\u044f\u043d\u0443 \u043f\u0440\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432 \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u0432\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u0438\u0437-\u0437\u0430 \u0438\u0445 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0441\u0442\u0438.         \u041c\u043e\u0436\u0435\u0442\u0435 \u0442\u0430\u043a\u0436\u0435 \u0438\u0445 \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c.         --&gt;         &lt;dependency&gt;             &lt;groupId&gt;commons-io&lt;\/groupId&gt;             &lt;artifactId&gt;commons-io&lt;\/artifactId&gt;             &lt;version&gt;2.4&lt;\/version&gt;         &lt;\/dependency&gt;          &lt;dependency&gt;             &lt;groupId&gt;commons-lang&lt;\/groupId&gt;             &lt;artifactId&gt;commons-lang&lt;\/artifactId&gt;             &lt;version&gt;2.6&lt;\/version&gt;         &lt;\/dependency&gt;          &lt;dependency&gt;             &lt;groupId&gt;commons-fileupload&lt;\/groupId&gt;             &lt;artifactId&gt;commons-fileupload&lt;\/artifactId&gt;             &lt;version&gt;1.3.1&lt;\/version&gt;         &lt;\/dependency&gt;     &lt;\/dependencies&gt;      &lt;build&gt;         &lt;plugins&gt;             &lt;plugin&gt;                 &lt;artifactId&gt;maven-war-plugin&lt;\/artifactId&gt;                 &lt;version&gt;2.4&lt;\/version&gt;                 &lt;configuration&gt;                     &lt;webXml&gt;src\/main\/webapp\/WEB-INF\/web.xml&lt;\/webXml&gt;                 &lt;\/configuration&gt;             &lt;\/plugin&gt;         &lt;\/plugins&gt;     &lt;\/build&gt; &lt;\/project&gt; <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u044b, \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u043a \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 Spring.<br \/>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u044f \u043e\u0431\u044b\u0447\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u044e \u043f\u0430\u043f\u043a\u0443 \u00abspring\u00bb \u0432 src\/main\/resources, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0445\u0440\u0430\u043d\u044f\u0442 \u0444\u0430\u0439\u043b\u044b \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 Spring \u0432 webapp\/WEB-INF\/*, \u043d\u043e \u044d\u0442\u043e \u0443\u0436\u0435 \u043a\u043e\u043c\u0443 \u043a\u0430\u043a \u0443\u0434\u043e\u0431\u043d\u043e. \u0421\u043a\u0430\u0436\u0443 \u0441\u0440\u0430\u0437\u0443, \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u0430 \u0431\u0443\u0434\u0435\u0442 2, \u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435 \u043c\u0435\u0440\u0435 \u044f \u0441\u0447\u0438\u0442\u0430\u044e, \u0447\u0442\u043e \u044d\u0442\u043e \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0432\u0435\u0440\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438. 1-\u0439 \u0444\u0430\u0439\u043b \u0431\u0443\u0434\u0435\u0442 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u043f\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u0431\u0438\u043d\u043e\u0432, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0411\u0414, \u0438 \u043f\u0440., \u0442\u0430\u043a \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 <u>\u0432\u0441\u0435\u0433\u043e<\/u> \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. 2-\u0439 \u0444\u0430\u0439\u043b \u2014 \u044d\u0442\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u044b DispatcherServlet, \u0432 \u043e\u0431\u0449\u0435\u043c \u0432\u0441\u0435, \u0447\u0442\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043e \u0443\u0436\u0435 \u0441 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c \u0441\u0442\u0440\u0430\u043d\u0438\u0446, \u0438 \u0432\u043e\u043e\u0431\u0449\u0435 c Spring MVC.<\/p>\n<p>  <b>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 <u>\u0432\u0441\u0435\u0433\u043e<\/u> \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f (src\/main\/resources\/spring\/applicationContext.xml):<\/b><\/p>\n<pre><code class=\"xml\">&lt;beans xmlns=&quot;http:\/\/www.springframework.org\/schema\/beans&quot;        xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot;        xmlns:context=&quot;http:\/\/www.springframework.org\/schema\/context&quot;        xmlns:mongo=&quot;http:\/\/www.springframework.org\/schema\/data\/mongo&quot;        xsi:schemaLocation=&quot;http:\/\/www.springframework.org\/schema\/beans         http:\/\/www.springframework.org\/schema\/beans\/spring-beans.xsd         http:\/\/www.springframework.org\/schema\/context         http:\/\/www.springframework.org\/schema\/context\/spring-context.xsd         http:\/\/www.springframework.org\/schema\/data\/mongo         http:\/\/www.springframework.org\/schema\/data\/mongo\/spring-mongo.xsd&quot;&gt;      &lt;!-- \u0412\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u044b\u0435 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0442\u0438\u043f\u0430 @Service, @Controller, @Repository... --&gt;     &lt;context:annotation-config\/&gt;      &lt;!--     \u0423\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c Spring\u0443 \u043f\u0430\u043a\u0435\u0442, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043a\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u044b,     \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u043d\u044b\u0435 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f\u043c\u0438 @Service, @Repository, \u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u0445 \u0431\u0438\u043d\u044b, \u043d\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043e\u043d \u0431\u0443\u0434\u0435\u0442 @Controller,     \u0442.\u043a. \u044d\u0442\u0438 \u043a\u043b\u0430\u0441\u0441\u044b \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u044b \u0431\u0443\u0434\u0443\u0442 \u0432 \u0434\u0440\u0443\u0433\u043e\u043c \u043c\u0435\u0441\u0442\u0435.     --&gt;     &lt;context:component-scan base-package=&quot;ru.habrahabr.sm&quot;&gt;         &lt;context:exclude-filter type=&quot;annotation&quot; expression=&quot;org.springframework.stereotype.Controller&quot;\/&gt;     &lt;\/context:component-scan&gt;      &lt;!--     \u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 properties \u0444\u0430\u0439\u043b \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e Spring (\u0442.\u0435. \u0441\u044e\u0434\u0430).     \u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a ${mongo.host} (\u043f\u0440\u0438\u043c\u0435\u0440 \u0441\u043c. \u043d\u0438\u0436\u0435)     --&gt;     &lt;context:property-placeholder location=&quot;classpath:database.properties&quot;\/&gt;      &lt;!-- \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0431\u0438\u043d 'mongo' --&gt;     &lt;mongo:mongo host=&quot;${mongo.host}&quot; port=&quot;${mongo.port}&quot;\/&gt;      &lt;!--     \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0431\u0438\u043d 'mongoDbFactory'.     \u0415\u0441\u043b\u0438 MongoDB \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438, \u0442\u043e \u043f\u043e\u043b\u044f username, password \u043c\u043e\u0436\u043d\u043e \u0443\u0431\u0440\u0430\u0442\u044c     --&gt;     &lt;mongo:db-factory             username=&quot;${mongo.username}&quot;             password=&quot;${mongo.password}&quot;             dbname=&quot;${mongo.db}&quot;             mongo-ref=&quot;mongo&quot;\/&gt;      &lt;bean id=&quot;mongoTemplate&quot; class=&quot;org.springframework.data.mongodb.core.MongoTemplate&quot;&gt;         &lt;constructor-arg name=&quot;mongoDbFactory&quot; ref=&quot;mongoDbFactory&quot;\/&gt;     &lt;\/bean&gt; &lt;\/beans&gt; <\/code><\/pre>\n<p>  <b>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 Spring MVC (src\/main\/resources\/spring\/dispatcherServlet.xml):<\/b><\/p>\n<pre><code class=\"xml\">&lt;beans xmlns=&quot;http:\/\/www.springframework.org\/schema\/beans&quot;        xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot;        xmlns:context=&quot;http:\/\/www.springframework.org\/schema\/context&quot;        xmlns:mvc=&quot;http:\/\/www.springframework.org\/schema\/mvc&quot;        xsi:schemaLocation=&quot;http:\/\/www.springframework.org\/schema\/beans         http:\/\/www.springframework.org\/schema\/beans\/spring-beans.xsd         http:\/\/www.springframework.org\/schema\/context         http:\/\/www.springframework.org\/schema\/context\/spring-context.xsd         http:\/\/www.springframework.org\/schema\/mvc         http:\/\/www.springframework.org\/schema\/mvc\/spring-mvc.xsd&quot;&gt;      &lt;!-- \u0412\u043a\u043b\u044e\u0447\u0430\u0435\u043c MVC \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 --&gt;     &lt;mvc:annotation-driven\/&gt;      &lt;!--     \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 MVC Resources     \u041f\u0440\u043e\u0449\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, \u0432\u0441\u0435 \u0444\u0430\u0439\u043b\u044b \u0438\u0437 \u043f\u0430\u043f\u043a\u0438 webapp\/resources\/ \u0431\u0443\u0434\u0443\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443: localhost\/resources\/     --&gt;     &lt;mvc:resources mapping=&quot;\/resources\/**&quot; location=&quot;\/resources\/&quot;\/&gt;      &lt;!-- \u0423\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c Spring MVC \u0433\u0434\u0435 \u0438\u0441\u043a\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u044b-\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u044b --&gt;     &lt;context:component-scan base-package=&quot;ru.habrahabr.sm&quot;&gt;         &lt;context:include-filter type=&quot;annotation&quot; expression=&quot;org.springframework.stereotype.Controller&quot; \/&gt;     &lt;\/context:component-scan&gt;      &lt;!-- \u0423\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c Spring MVC \u0433\u0434\u0435 \u0431\u0443\u0434\u0443\u0442 \u043b\u0435\u0436\u0430\u0442\u044c \u043d\u0430\u0448\u0438 View\u0448\u043a\u0438, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e &quot;\/WEB-INF\/pages\/&quot; --&gt;     &lt;bean class=&quot;org.springframework.web.servlet.view.InternalResourceViewResolver&quot;&gt;         &lt;property name=&quot;prefix&quot; value=&quot;\/WEB-INF\/pages\/&quot;\/&gt;         &lt;property name=&quot;suffix&quot; value=&quot;.jsp&quot;\/&gt;     &lt;\/bean&gt; &lt;\/beans&gt; <\/code><\/pre>\n<p>  \u041e\u0442\u043b\u0438\u0447\u043d\u043e, Spring \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d, \u043d\u043e \u0435\u0441\u043b\u0438 \u0432\u044b \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0447\u0438\u0442\u0430\u043b\u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b, \u0442\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438, \u0447\u0442\u043e \u0432 <u>applicationContext.xml<\/u> \u043c\u044b \u0442\u044f\u043d\u0443\u043b\u0438 &quot;<u>classpath:database.properties<\/u>&quot;. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0444\u0430\u0439\u043b \u0432 \u00absrc\/main\/resources\/database.properties\u00bb \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435\u043c:<\/p>\n<pre><code class=\"java\">mongo.host=localhost mongo.port=27017 mongo.db=mydb mongo.username=username mongo.password=password <\/code><\/pre>\n<p>  \u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u0441\u043b\u0435 \u0437\u043d\u0430\u043a\u0430 &#8216;=&#8217; \u0441\u0432\u043e\u0438\u043c\u0438. \u0417\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u0447\u0442\u043e \u043f\u043e\u043b\u044f username, password \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435, \u0438 \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043d\u0435 \u043d\u0443\u0436\u043d\u0430 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a MongoDB, \u0437\u0430\u0433\u043b\u044f\u043d\u0438\u0442\u0435 \u0432 applicationContext.xml, \u0442\u0430\u043c \u0443\u043a\u0430\u0437\u0430\u043d\u043e \u043a\u0430\u043a\u0438\u0435 \u043f\u043e\u043b\u044f \u043d\u0443\u0436\u043d\u043e \u0443\u0431\u0440\u0430\u0442\u044c. \u0421\u0440\u0430\u0437\u0443 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0434\u043b\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043b\u043e\u0433\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f (src\/main\/resources\/log4j.properties):<\/p>\n<pre><code class=\"java\">log4j.rootLogger=INFO, stdout  # Direct log messages to stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.target=System.out log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.conversionPattern=%d{dd.MM.yy HH:mm:ss} %5p - %m%n log4j.appender.stdout.encoding=UTF-8 <\/code><\/pre>\n<p>  \u041d\u0430\u043a\u043e\u043d\u0435\u0446 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u044e\u0449\u0435\u043c\u0443 \u044d\u0442\u0430\u043f\u0443 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f Java Web \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u2014 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 web.xml (src\/main\/webapp\/WEB-INF\/web.xml):<\/p>\n<pre><code class=\"xml\">&lt;web-app version=&quot;2.4&quot;          xmlns=&quot;http:\/\/java.sun.com\/xml\/ns\/j2ee&quot;          xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot;          xsi:schemaLocation=&quot;http:\/\/java.sun.com\/xml\/ns\/j2ee          http:\/\/java.sun.com\/xml\/ns\/j2ee\/web-app_2_4.xsd&quot;&gt;      &lt;!-- Spring Application Context --&gt;     &lt;context-param&gt;         &lt;param-name&gt;contextConfigLocation&lt;\/param-name&gt;         &lt;param-value&gt;classpath:spring\/applicationContext.xml&lt;\/param-value&gt;     &lt;\/context-param&gt;      &lt;listener&gt;         &lt;listener-class&gt;             org.springframework.web.context.ContextLoaderListener         &lt;\/listener-class&gt;     &lt;\/listener&gt;     &lt;!-- \/Spring Application Context --&gt;      &lt;!-- Spring Dispatcher Servlet Context --&gt;     &lt;servlet&gt;         &lt;servlet-name&gt;dispatcher&lt;\/servlet-name&gt;         &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;\/servlet-class&gt;         &lt;init-param&gt;             &lt;param-name&gt;contextConfigLocation&lt;\/param-name&gt;             &lt;param-value&gt;classpath:spring\/dispatcherServlet.xml&lt;\/param-value&gt;         &lt;\/init-param&gt;         &lt;load-on-startup&gt;1&lt;\/load-on-startup&gt;     &lt;\/servlet&gt;      &lt;servlet-mapping&gt;         &lt;servlet-name&gt;dispatcher&lt;\/servlet-name&gt;         &lt;url-pattern&gt;\/&lt;\/url-pattern&gt;     &lt;\/servlet-mapping&gt;     &lt;!-- \/Spring Dispatcher Servlet Context --&gt;      &lt;!-- Filters --&gt;      &lt;!-- Character Filter --&gt;     &lt;filter&gt;         &lt;filter-name&gt;encodingFilter&lt;\/filter-name&gt;         &lt;filter-class&gt;org.springframework.web.filter.CharacterEncodingFilter&lt;\/filter-class&gt;         &lt;init-param&gt;             &lt;param-name&gt;encoding&lt;\/param-name&gt;             &lt;param-value&gt;UTF-8&lt;\/param-value&gt;         &lt;\/init-param&gt;         &lt;init-param&gt;             &lt;param-name&gt;forceEncoding&lt;\/param-name&gt;             &lt;param-value&gt;true&lt;\/param-value&gt;         &lt;\/init-param&gt;     &lt;\/filter&gt;      &lt;filter-mapping&gt;         &lt;filter-name&gt;encodingFilter&lt;\/filter-name&gt;         &lt;url-pattern&gt;\/*&lt;\/url-pattern&gt;     &lt;\/filter-mapping&gt;     &lt;!-- \/Character Filter --&gt;      &lt;!-- \/Filters --&gt;  &lt;\/web-app&gt; <\/code><\/pre>\n<p>  \u041d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u0443 \u0412\u0430\u0441 \u0443\u0436\u0435 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0444\u0430\u0439\u043b\u043e\u0432 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435: <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/3d5\/9c1\/c19\/3d59c1c1926b5fca88f812804d8e202d.jpg\"\/><br \/>  \u0412 \u043f\u0430\u043f\u043a\u0443 \u00absrc\/webapp\/resources\/\u00bb \u043c\u043e\u0436\u0435\u0442\u0435 \u043b\u043e\u0436\u0438\u0442\u044c \u043b\u044e\u0431\u043e\u0439 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043a\u043e\u043d\u0442\u0435\u043d\u0442 (\u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438, \u0441\u0442\u0438\u043b\u0438, js \u0441\u043a\u0440\u0438\u043f\u0442\u044b, \u0438 \u0442.\u0434.).<\/p>\n<h5><b>\u041d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a\u043e\u0434\u0430<\/b><\/h5>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446-\u0442\u043e \u043f\u0440\u043e\u0435\u043a\u0442 \u0441\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d, \u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u043a \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u0441\u0430\u043c\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u043b\u043e\u044f \u043f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0411\u0414. \u0425\u043e\u0447\u0443 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435: \u0432 MongoDB \u043d\u0435\u0442 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0433\u043e AUTO_INCREMENT PK \u043f\u043e\u043b\u044f, \u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0443 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f ID \u0442\u0430\u043a\u043e\u0433\u043e \u0432\u0438\u0434\u0430: ObjectId(\u00ab5326b46f44ae9e6328b4566c\u00bb). Spring Data \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442 \u044d\u0442\u043e\u0442 ID \u043a\u0430\u043a \u043e\u0431\u044a\u0435\u043a\u0442 \u0442\u0438\u043f\u0430 String. \u041f\u0440\u043e\u0449\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0443 \u0432\u0430\u0441 ID \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0431\u044b\u043b\u043e \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u043c \u0438 \u0430\u0432\u0442\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u044e\u0449\u0438\u043c\u0441\u044f, \u0442\u043e \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043d\u0430\u0434 \u044d\u0442\u0438\u043c \u043f\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e. \u041d\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0432 \u044d\u0442\u043e\u043c \u043d\u0435\u0442 \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e \u0438 \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u044d\u0442\u043e\u0433\u043e \u0431\u043e\u044f\u0442\u044c\u0441\u044f, \u0430 \u044f \u0441\u0435\u0439\u0447\u0430\u0441 \u043e\u043f\u0438\u0448\u0443 \u043a\u0430\u043a \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f! \u0415\u0441\u043b\u0438 \u0436\u0435 \u0412\u0430\u0441 \u0443\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442 \u0438 \u0434\u043b\u0438\u043d\u043d\u044b\u0439 String \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 ID \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u0442\u043e \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u0432\u0441\u0435 \u043a\u043b\u0430\u0441\u0441\u044b (\u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435) \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u043e\u0432\u043e \u00abSequence\u00bb.<\/p>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e \u0432 \u0411\u0414 \u0441 \u0438\u043c\u0435\u043d\u0435\u043c sequences. \u0418 \u0440\u0443\u043a\u0430\u043c\u0438 \u0432\u043d\u043e\u0441\u0438\u043c \u0442\u0443\u0434\u0430 \u043e\u0431\u044a\u0435\u043a\u0442 (insert):<\/p>\n<pre><code class=\"javascript\">{     &quot;_id&quot; : &quot;contacts&quot;,     &quot;sequence&quot; : 0 } <\/code><\/pre>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043f\u0430\u0440\u0443: \u00ab\u0438\u043c\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b\u00bb \u2014 \u00ab\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 ID\u00bb, \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b(\u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438), \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0412\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0443 \u0441\u0430\u043c\u043e\u043f\u0438\u0441\u043d\u0443\u044e AUTO_INCREMENT \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e, \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u043d\u0435\u0441\u0442\u0438 \u043d\u043e\u0432\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c, \u043a\u0430\u043a \u0443\u043a\u0430\u0437\u0430\u043d\u043e \u0432\u044b\u0448\u0435, \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u00abcontacts\u00bb \u0432\u0432\u0435\u0434\u0438\u0442\u0435 \u0438\u043c\u044f \u043d\u0443\u0436\u043d\u043e\u0439 \u0412\u0430\u043c \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438. \u041a\u0441\u0442\u0430\u0442\u0438, \u0435\u0441\u043b\u0438 \u0435\u0449\u0435 \u043d\u0435 \u0437\u043d\u0430\u0435\u0442\u0435 \u043a\u0430\u043a\u043e\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442(management-tool) \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f MongoDB, \u0442\u043e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e <a href=\"http:\/\/robomongo.org\/\">Robomongo<\/a>.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u043b\u0430\u0441\u0441-\u043e\u0431\u0435\u0440\u0442\u043a\u0443 \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438:<\/p>\n<pre><code class=\"java\">package ru.habrahabr.sm.model;  import org.springframework.data.annotation.Id; import org.springframework.data.mongodb.core.mapping.Document;  \/**  * Date: 26.03.2014  * Time: 15:38  *  * @author Ruslan Molchanov (ruslanys@gmail.com)  *\/ @Document(collection = Sequence.COLLECTION_NAME) public class Sequence {     public static final String COLLECTION_NAME = &quot;sequences&quot;;      @Id     private String id;     private Long sequence;      public Sequence() {     }      public String getId() {         return id;     }      public void setId(String id) {         this.id = id;     }      public Long getSequence() {         return sequence;     }      public void setSequence(Long sequence) {         this.sequence = sequence;     } } <\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0437\u0430\u043f\u0438\u0441\u044c &quot;@Document(collection = Sequence.COLLECTION_NAME)&quot; \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c &quot;@Document(collection = \u00absequences\u00bb)&quot;, \u043d\u043e \u044d\u0442\u043e \u0443\u0436\u0435 \u0441\u043a\u043e\u0440\u0435\u0435 \u0434\u0435\u043b\u043e \u0432\u043a\u0443\u0441\u0430. \u041f\u043b\u044e\u0441 \u0435\u0441\u0442\u044c \u043e\u0434\u043d\u043e \u044f\u0432\u043d\u043e\u0435 \u0434\u043e\u0441\u0442\u043e\u0438\u043d\u0441\u0442\u0432\u043e \u0443 \u0442\u0430\u043a\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430, \u0434\u0430\u043b\u044c\u0448\u0435 \u043f\u043e\u0439\u043c\u0435\u0442\u0435 \u043a\u0430\u043a\u043e\u0435.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u043f\u0438\u0448\u0435\u043c \u0441\u043b\u043e\u0439 \u043f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0411\u0414 \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0430-\u043e\u0431\u0435\u0440\u0442\u043a\u0438 &quot;<u>Sequence<\/u>&quot;, \u0441\u043a\u0430\u0436\u0443 \u0441\u0440\u0430\u0437\u0443, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0440\u0430\u0441\u0442\u044f\u0433\u0438\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u044e, \u044f \u043d\u0435 \u0431\u0443\u0434\u0443 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b \u0434\u043b\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0438 DAO, \u0431\u0443\u0434\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0443\u0436\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f\u043c\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 (\u0445\u043e\u0442\u044f \u044d\u0442\u043e \u0432\u0440\u043e\u0434\u0435 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e), \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u0412\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442\u0435 \u043e \u0447\u0435\u043c \u0438\u0434\u0435\u0442 \u0440\u0435\u0447\u044c.  <\/p>\n<pre><code class=\"java\">package ru.habrahabr.sm.dao;  import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.mongodb.core.FindAndModifyOptions; import org.springframework.data.mongodb.core.MongoOperations; import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Query; import org.springframework.data.mongodb.core.query.Update; import org.springframework.stereotype.Repository; import ru.habrahabr.sm.exceptions.SequenceException; import ru.habrahabr.sm.model.Sequence;  \/**  * \u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0432\u0437\u044f\u0442 \u0441 \u0441\u0430\u0439\u0442\u0430 mkyong,  * \u0442\u043e\u0447\u043d\u0443\u044e \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430\u0439\u0442\u0438 \u043d\u0435 \u0441\u043c\u043e\u0433  *\/ @Repository public class SequenceDao {     @Autowired private MongoOperations mongoOperations;      public Long getNextSequenceId(String key) {         \/\/ \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442 Sequence \u043f\u043e \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044e \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438         Query query = new Query(Criteria.where(&quot;id&quot;).is(key));          \/\/ \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u043c \u043f\u043e\u043b\u0435 sequence \u043d\u0430 \u0435\u0434\u0438\u043d\u0438\u0446\u0443         Update update = new Update();         update.inc(&quot;sequence&quot;, 1);          \/\/ \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043e\u043f\u0446\u0438\u044e, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442         FindAndModifyOptions options = new FindAndModifyOptions();         options.returnNew(true);          \/\/ \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043c\u0430\u0433\u0438\u0438 :)         Sequence sequence = mongoOperations.findAndModify(query, update, options, Sequence.class);          \/\/ if no sequence throws SequenceException         if(sequence == null) throw new SequenceException(&quot;Unable to get sequence for key: &quot; + key);          return sequence.getSequence();     } } <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043a\u043b\u0430\u0441\u0441 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u0432 \u043d\u0430\u0448\u0435\u0439 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 `sequences` \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0411\u0414 (\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u044f \u043f\u0438\u0441\u0430\u043b \u0432\u044b\u0448\u0435):<\/p>\n<pre><code class=\"java\">package ru.habrahabr.sm.exceptions;  \/**  * Date: 26.03.2014  * Time: 16:09  *  * @author Ruslan Molchanov (ruslanys@gmail.com)  *\/ public class SequenceException extends RuntimeException {     public SequenceException(String message) {         super(message);     } } <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0432 \u0411\u0414 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e `contacts`, \u0438 \u043a\u043b\u0430\u0441\u0441-\u043e\u0431\u0435\u0440\u0442\u043a\u0443:<\/p>\n<pre><code class=\"java\">package ru.habrahabr.sm.model;  import org.springframework.data.annotation.Id; import org.springframework.data.mongodb.core.mapping.Document;  import java.io.Serializable;  \/**  * Date: 26.03.2014  * Time: 15:29  *  * @author Ruslan Molchanov (ruslanys@gmail.com)  *\/ @Document(collection = Contact.COLLECTION_NAME) public class Contact implements Serializable {     public static final String COLLECTION_NAME = &quot;contacts&quot;;      @Id     private Long id;     \/* *******************************************************      \u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435, \u0447\u0442\u043e\u0431\u044b ID \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0431\u044b\u043b\u0430 \u0430\u0432\u0442\u043e\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u0430\u044f      \u0441\u0442\u0440\u043e\u043a\u0430 (\u043e\u0431 \u044d\u0442\u043e\u043c \u044f \u043f\u0438\u0441\u0430\u043b \u0432 \u043f\u043e\u0441\u0442\u0435), \u0442\u043e \u043e\u043f\u0438\u0448\u0438\u0442\u0435 \u043f\u043e\u043b\u0435 ID \u0442\u0430\u043a:      @Id      private String id;      ********************************************************* *\/      private String name;     private String number;     private String email;      public Contact() {     }      public Contact(String name, String number, String email) {         this.name = name;         this.number = number;         this.email = email;     }      public Long getId() {         return id;     }      public void setId(Long id) {         this.id = id;     }      public String getName() {         return name;     }      public void setName(String name) {         this.name = name;     }      public String getNumber() {         return number;     }      public void setNumber(String number) {         this.number = number;     }      public String getEmail() {         return email;     }      public void setEmail(String email) {         this.email = email;     } } <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u043f\u0438\u0448\u0435\u043c DAO \u0441\u043b\u043e\u0439 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u00abContact\u00bb:<\/p>\n<pre><code class=\"java\">package ru.habrahabr.sm.dao;  import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.mongodb.core.MongoOperations; import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Query; import org.springframework.stereotype.Repository; import ru.habrahabr.sm.model.Contact;  import java.util.List;  \/**  * Date: 26.03.2014  * Time: 19:13  *  * @author Ruslan Molchanov (ruslanys@gmail.com)  *\/ @Repository public class ContactDao {     @Autowired private MongoOperations mongoOperations;      public void save(Contact contact) {         mongoOperations.save(contact);     }      public Contact get(Long id) {         return mongoOperations.findOne(Query.query(Criteria.where(&quot;id&quot;).is(id)), Contact.class);     }      public List&lt;Contact&gt; getAll() {         return mongoOperations.findAll(Contact.class);     }      public void remove(Long id) {         mongoOperations.remove(Query.query(Criteria.where(&quot;id&quot;).is(id)), Contact.class);     } } <\/code><\/pre>\n<p>\u0425\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0411\u0414 \u043c\u043e\u0436\u043d\u043e \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 DAO \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"java\">mongoOperations.updateFirst(query, update, Contact.class); <\/code><\/pre>\n<p>\u0420\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u044d\u0442\u0438\u043c \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0449\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0438 \u043d\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442 \u0434\u043b\u044f \u0412\u0430\u0441 \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u0435\u0439. \u041d\u043e \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0432\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435:<\/p>\n<pre><code class=\"java\">mongoOperations.save(contact); <\/code><\/pre>\n<p> \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e ID \u0443\u0436\u0435 \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u0435\u043d, \u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0432 \u0411\u0414, \u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 \u0411\u0414 \u043f\u043e\u0434 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c ID.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u043f\u0438\u0448\u0435\u043c \u0441\u043b\u043e\u0439 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438 \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0430 \u00abContact\u00bb:<\/p>\n<pre><code class=\"java\">package ru.habrahabr.sm.services;  import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import ru.habrahabr.sm.dao.ContactDao; import ru.habrahabr.sm.dao.SequenceDao; import ru.habrahabr.sm.model.Contact;  import java.util.List;  \/**  * Date: 26.03.2014  * Time: 20:09  *  * @author Ruslan Molchanov (ruslanys@gmail.com)  *\/ @Service public class ContactService {     @Autowired private SequenceDao sequenceDao;     @Autowired private ContactDao contactDao;          public void add(Contact contact) {         contact.setId(sequenceDao.getNextSequenceId(Contact.COLLECTION_NAME));         contactDao.save(contact);     }          public void update(Contact contact) {         contactDao.save(contact);     }          public Contact get(Long id) {         return contactDao.get(id);     }          public List&lt;Contact&gt; getAll() {         return contactDao.getAll();     }          public void remove(Long id) {         contactDao.remove(id);     } } <\/code><\/pre>\n<p>  \u041d\u0443 \u0432\u043e\u0442, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438 \u0432\u0441\u0435, \u0432\u0441\u0435, \u0447\u0442\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u0441\u0432\u044f\u0437\u043a\u0438 Spring + MongoDB \u043c\u044b \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u043b\u0438, \u0442.\u0435. \u0442\u0435\u043f\u0435\u0440\u044c \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f ORM Spring Data \u0441 \u0443\u0436\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u043e\u0439 \u043a \u043f\u0440\u043e\u0435\u043a\u0442\u0443 MongoDB, \u043d\u043e \u0440\u0430\u0437 \u044f \u043e\u0431\u0435\u0449\u0430\u043b \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a\u0430 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u0411\u0414, \u0442\u043e \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0435\u0449\u0435 \u043a\u043b\u0430\u0441\u0441-\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440:<\/p>\n<pre><code class=\"java\">package ru.habrahabr.sm.web;  import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.servlet.ModelAndView; import ru.habrahabr.sm.model.Contact; import ru.habrahabr.sm.services.ContactService;  \/**  * Date: 26.03.2014  * Time: 20:30  *  * @author Ruslan Molchanov (ruslanys@gmail.com)  *\/ @Controller public class MainController {     @Autowired private ContactService contactService;      @RequestMapping(value = &quot;\/&quot;, method = RequestMethod.GET)     public ModelAndView showAll() {         ModelAndView modelAndView = new ModelAndView(&quot;all&quot;);          modelAndView.addObject(&quot;contacts&quot;, contactService.getAll());          return modelAndView;     }      @RequestMapping(value = &quot;\/add&quot;, method = RequestMethod.GET)     public ModelAndView showAddForm() {         return new ModelAndView(&quot;add_form&quot;, &quot;contact&quot;, new Contact());     }      @RequestMapping(value = &quot;\/add&quot;, method = RequestMethod.POST)     public String addContact(@ModelAttribute(&quot;contact&quot;) Contact contact) {         if(contact.getId() == null) contactService.add(contact);         else contactService.update(contact);          return &quot;redirect:\/&quot;;     }      @RequestMapping(value = &quot;\/edit&quot;, method = RequestMethod.GET)     public ModelAndView showEditForm(@RequestParam(required = true) Long id) {         return new ModelAndView(&quot;add_form&quot;, &quot;contact&quot;, contactService.get(id));     }      @RequestMapping(value = &quot;\/delete&quot;, method = RequestMethod.GET)     public String deleteContact(@RequestParam(required = true) Long id) {         contactService.remove(id);          return &quot;redirect:\/&quot;;     } } <\/code><\/pre>\n<p>  \u041d\u0443 \u0438 \u0432\u044c\u044e\u0448\u043a\u0438 (src\/webapp\/WEB-INF\/pages\/add_form.jsp):<\/p>\n<pre><code class=\"html\">&lt;%@ taglib prefix=&quot;form&quot; uri=&quot;http:\/\/www.springframework.org\/tags\/form&quot; %&gt; &lt;%@ page contentType=&quot;text\/html;charset=UTF-8&quot; language=&quot;java&quot; %&gt; &lt;html&gt; &lt;head&gt;     &lt;title&gt;\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0430\u043a\u0442&lt;\/title&gt; &lt;\/head&gt; &lt;body&gt; &lt;form:form method=&quot;POST&quot; action=&quot;\/add&quot; modelAttribute=&quot;contact&quot;&gt;     &lt;form:hidden path=&quot;id&quot; \/&gt;     &lt;table&gt;         &lt;tr&gt;             &lt;td&gt;Name:&lt;\/td&gt;             &lt;td&gt;&lt;form:input path=&quot;name&quot; \/&gt;&lt;\/td&gt;         &lt;\/tr&gt;         &lt;tr&gt;             &lt;td&gt;Number:&lt;\/td&gt;             &lt;td&gt;&lt;form:input path=&quot;number&quot; \/&gt;&lt;\/td&gt;         &lt;\/tr&gt;         &lt;tr&gt;             &lt;td&gt;E-mail:&lt;\/td&gt;             &lt;td&gt;&lt;form:input path=&quot;email&quot; \/&gt;&lt;\/td&gt;         &lt;\/tr&gt;         &lt;tr&gt;             &lt;td colspan=&quot;2&quot;&gt;                 &lt;input type=&quot;submit&quot; \/&gt;             &lt;\/td&gt;         &lt;\/tr&gt;     &lt;\/table&gt; &lt;\/form:form&gt; &lt;\/body&gt; &lt;\/html&gt; <\/code><\/pre>\n<p>  \u0415\u0449\u0435 \u043e\u0434\u043d\u0430 (src\/webapp\/WEB-INF\/all.jsp):<\/p>\n<pre><code class=\"html\">&lt;%@ page contentType=&quot;text\/html;charset=UTF-8&quot; language=&quot;java&quot; %&gt; &lt;%@ taglib prefix=&quot;c&quot; uri=&quot;http:\/\/java.sun.com\/jsp\/jstl\/core&quot; %&gt;  &lt;html&gt; &lt;head&gt;     &lt;title&gt;\u0412\u0441\u0435 \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u044b&lt;\/title&gt; &lt;\/head&gt; &lt;body&gt; &lt;table width=&quot;600px&quot;&gt;     &lt;tr&gt;         &lt;td&gt;&lt;b&gt;ID&lt;\/b&gt;&lt;\/td&gt;         &lt;td&gt;&lt;b&gt;Name&lt;\/b&gt;&lt;\/td&gt;         &lt;td&gt;&lt;b&gt;Number&lt;\/b&gt;&lt;\/td&gt;         &lt;td&gt;&lt;b&gt;E-mail&lt;\/b&gt;&lt;\/td&gt;         &lt;td&gt;&lt;b&gt;Action&lt;\/b&gt;&lt;\/td&gt;     &lt;\/tr&gt;     &lt;c:forEach var=&quot;contact&quot; items=&quot;${contacts}&quot;&gt;         &lt;tr&gt;             &lt;td&gt;${contact.id}&lt;\/td&gt;             &lt;td&gt;${contact.name}&lt;\/td&gt;             &lt;td&gt;${contact.number}&lt;\/td&gt;             &lt;td&gt;${contact.email}&lt;\/td&gt;             &lt;td&gt;&lt;a href=&quot;\/edit?id=${contact.id}&quot;&gt;Edit&lt;\/a&gt; | &lt;a href=&quot;\/delete?id=${contact.id}&quot;&gt;Delete&lt;\/a&gt;&lt;\/td&gt;         &lt;\/tr&gt;     &lt;\/c:forEach&gt;     &lt;tr&gt;         &lt;td colspan=&quot;5&quot;&gt;             &lt;a href=&quot;\/add&quot;&gt;\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u044c&lt;\/a&gt;         &lt;\/td&gt;     &lt;\/tr&gt; &lt;\/table&gt; &lt;\/body&gt; &lt;\/html&gt; <\/code><\/pre>\n<p>  \u041d\u0443 \u0432\u043e\u0442 \u0438 \u0432\u0441\u0435, \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c, \u0438 \u0432\u0443\u0430\u043b\u044f:<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/0e4\/3d4\/45e\/0e43d445e4354c01c46750e4e7663000.jpg\"\/><\/p>\n<p>  \u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438: <a href=\"https:\/\/db.tt\/2zfWWsJT\">db.tt\/2zfWWsJT<\/a><\/p>\n<p>  P.S. \u0411\u0443\u0434\u0443 \u0441\u0447\u0430\u0441\u0442\u043b\u0438\u0432, \u0435\u0441\u043b\u0438 \u043a\u043e\u043c\u0443-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u044d\u0442\u043e\u0442 \u043f\u043e\u0441\u0442. \u0411\u0443\u0434\u0443 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u0435\u043d \u0437\u0430 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0438 \u0438 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f. \t\t\t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/217391\/\"> http:\/\/habrahabr.ru\/post\/217391\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\"> \t\t\t<img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/6df\/7f2\/670\/6df7f2670123a6642cf9814bd41486de.png\"\/><\/p>\n<p>  \u041f\u043e\u0438\u0441\u043a\u0430\u043b \u043d\u0430 \u0445\u0430\u0431\u0440\u0435 \u0441\u0445\u043e\u0436\u0438\u0435 \u0441\u0442\u0430\u0442\u044c\u0438, \u043d\u0430\u0448\u0435\u043b \u0442\u043e\u043b\u044c\u043a\u043e <a href=\"http:\/\/habrahabr.ru\/post\/118783\/\">Morphia \u2014 \u043b\u0435\u0433\u043a\u0438\u0439 ORM \u0434\u043b\u044f MongoDB, \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0439 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f\u043c\u0438<\/a>, \u043d\u0438\u0447\u0435\u0433\u043e \u043f\u043e \u0441\u0432\u044f\u0437\u043a\u0435 Spring Data + MongoDB \u043d\u0435 \u043d\u0430\u0448\u043b\u043e\u0441\u044c, \u0432 \u0441\u0432\u044f\u0437\u0438 \u0441 \u044d\u0442\u0438\u043c \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u043e\u0441\u0442 \u0438\u0437 \u0440\u0430\u0437\u0434\u0435\u043b\u0430 \u00ab\u0434\u043b\u044f \u0441\u0430\u043c\u044b\u0445 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0445\u00bb \u043f\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e \u0441\u0432\u044f\u0437\u043a\u0438 Spring + MongoDB.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-217391","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/217391","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=217391"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/217391\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=217391"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=217391"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=217391"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}