{"id":296635,"date":"2019-12-30T21:00:19","date_gmt":"2019-12-30T21:00:19","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=296635"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=296635","title":{"rendered":"\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0438 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Spring Security \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/482552\/\">\u0414\u043e\u0431\u0440\u044b\u0439 \u0434\u0435\u043d\u044c!<\/p>\n<p>  \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0432\u0435\u0431 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Spring Boot \u0438 Spring Security. \u0412 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043d\u043e\u0432\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f, \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\u043c \u0441\u0430\u0439\u0442\u0430 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0440\u043e\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<br \/>  \u0413\u043b\u0430\u0432\u043d\u0430\u044f \u0446\u0435\u043b\u044c \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\u043c \u0441\u0430\u0439\u0442\u0430 \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0440\u043e\u043b\u044f\u043c\u0438.<\/p>\n<h3>\u0427\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u0437 \u0441\u0435\u0431\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435<\/h3>\n<p>  \u0421\u0430\u0439\u0442 \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\u043c: <\/p>\n<ul>\n<li>\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0432\u0441\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c: \u0433\u043b\u0430\u0432\u043d\u0430\u044f, \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0438 \u043b\u043e\u0433\u0438\u043d\u0430;<\/li>\n<li>\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430\u044f \u0434\u043b\u044f \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439: \u043d\u043e\u0432\u043e\u0441\u0442\u0438;<\/li>\n<li>\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430\u044f \u0434\u043b\u044f \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430.<\/li>\n<\/ul>\n<p>  <\/p>\n<h3>\u0427\u0442\u043e \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c<\/h3>\n<p>  <\/p>\n<ul>\n<li>JDK 8+;<\/li>\n<li>Intellij Idea;<\/li>\n<li>Spring (Spring Boot, Spring MVC, Spring Security);<\/li>\n<li>Hibernate;<\/li>\n<li>JSP;<\/li>\n<li>PostgreSQL.<\/li>\n<\/ul>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h3>\u0421\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435<\/h3>\n<p>  <\/p>\n<ol>\n<li>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439.<\/li>\n<li>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0432 IDE.<\/li>\n<li>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043f\u0440\u043e\u0435\u043a\u0442\u0430 (\u043f\u0430\u043a\u0435\u0442\u043e\u0432).<\/li>\n<li>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439, \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432, \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432, \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u0432 \u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0439.<\/li>\n<li>\u0417\u0430\u043f\u0443\u0441\u043a \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/li>\n<\/ol>\n<p>  <\/p>\n<h3>1. \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439<\/h3>\n<p>  <b>Controller <\/b>\u2013 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u0438\u043f \u043a\u043b\u0430\u0441\u0441\u0430, \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0439 \u0432 MVC \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445. \u041f\u043e\u0445\u043e\u0436 \u043d\u0430 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u043b\u0435\u0442 HttpServlet, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438 HttpServletRequest \u0438 HttpServletResponse, \u043d\u043e \u0441 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u044b\u043c\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u043e\u0442 Spring Framework. <br \/>  <b>Repository<\/b> \u2013 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u043a\u043b\u0430\u0441\u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u0447\u043d\u044f<br \/>  \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0440\u0430\u0431\u043e\u0442 \u043f\u043e \u043f\u043e\u0438\u0441\u043a\u0443, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044e \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044e \u0434\u0430\u043d\u043d\u044b\u0445. \u0410\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 DAO.<br \/>  <b>Service<\/b> \u2013 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u043a\u043b\u0430\u0441\u0441 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u043c \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0431\u0438\u0437\u043d\u0435\u0441 \u043b\u043e\u0433\u0438\u043a\u0438.<br \/>  <b>Configuration<\/b> \u2013 \u044d\u0442\u0430 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442 bean-\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b.<br \/>  <b>Autowired<\/b> \u2013 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044f. \u0424\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u044d\u0442\u043e\u0439 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0431\u043e\u0442\u0438\u0442\u044c\u0441\u044f \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u043b\u0443\u0447\u0448\u0435 \u0432\u0441\u0435\u0433\u043e Bean&#8217;\u0443 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0434\u0440\u0443\u0433\u043e\u0433\u043e Bean&#8217;a. Spring \u0441\u0430\u043c \u043d\u0430\u0439\u0434\u0435\u0442 \u043d\u0443\u0436\u043d\u044b\u0439 Bean \u0438 \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u0438\u0442 \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043e\u0442\u043c\u0435\u0447\u0435\u043d\u043e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0435\u0439.<\/p>\n<h4>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e Spring Security<\/h4>\n<p>  \u0421\u0430\u043c\u044b\u043c \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <b>SecurityContextHolder<\/b>. \u0412 \u043d\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435 (\u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0430\u043b\u0435), \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u043c \u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c. Spring Security \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 <b>Authentication<\/b>, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0441\u0435\u0441\u0441\u0438\u0438. <\/p>\n<p>  \u00ab\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u00bb \u2013 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e Object. \u0412 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c<br \/>  \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u043a \u043a\u043b\u0430\u0441\u0441\u0443 <b>UserDetails<\/b>. <b>UserDetails <\/b>\u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c, \u043a\u0430\u043a \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u043c\u0435\u0436\u0434\u0443 \u0411\u0414 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u0442\u0435\u043c \u0447\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f Spring Security \u0432\u043d\u0443\u0442\u0440\u0438 <b>SecurityContextHolder<\/b>.<\/p>\n<p>  \u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f <b>UserDetails <\/b>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <b>UserDetailsService<\/b>, \u0441 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c:<\/p>\n<pre><code class=\"java\">UserDetails loadUserByUsername(String username) throws UsernameNotFoundException  <\/code><\/pre>\n<p>  <\/p>\n<h3>2. \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0432 IDE<\/h3>\n<p>  \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0441\u0431\u043e\u0440\u043a\u0438 Maven. <\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/k4\/x-\/yv\/k4x-yvce2pkv81gn4o-5hmxwgpo.png\"\/><\/p>\n<p>  \u041f\u043e\u0434 <b>GroupId<\/b> \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442\u0441\u044f \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 (\u0438\u043b\u0438 \u0432\u0430\u0448\u0435 \u043b\u0438\u0447\u043d\u043e\u0435 \u0434\u043e\u043c\u0435\u043d\u043d\u043e\u0435 \u0438\u043c\u044f), \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043f\u0440\u043e\u0435\u043a\u0442. <b>ArtefactId <\/b> \u2013 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/t8\/t4\/ep\/t8t4epn19a0gytk7lz1aviwzm0k.png\"\/><\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043e\u0442\u0440\u043e\u0435\u0442\u0441\u044f \u0444\u0430\u0439\u043b <b>pom.xml<\/b>, Idea \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0430\u0432\u0442\u043e\u0438\u043c\u043f\u043e\u0440\u0442 \u2013 \u043d\u0435 \u043e\u0442\u043a\u0430\u0437\u044b\u0432\u0430\u0439\u0442\u0435\u0441\u044c. \u0412 \u044d\u0442\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c\u0441\u044f \u0432\u0441\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 (\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438), \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435. <\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/m9\/xd\/au\/m9xdaux9kaa3zly9u5e_lp1kkqg.png\"\/><\/p>\n<h3>3. \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043f\u0440\u043e\u0435\u043a\u0442\u0430 (\u043f\u0430\u043a\u0435\u0442\u043e\u0432)<\/h3>\n<p>  \u0421\u0440\u0430\u0437\u0443 \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043f\u0430\u043a\u0435\u0442\u043e\u0432. \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0430 \u043d\u0438\u0436\u0435.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ly\/js\/z_\/lyjsz_zy6cq4ls7sd3_k0p9y8zw.png\"\/><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043a\u043e\u0440\u043e\u0442\u043a\u043e \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u043f\u0430\u043a\u0435\u0442\u0435:<\/p>\n<ul>\n<li><b>src\\main\\java\\com\\boots\\config<\/b> \u2014 \u043a\u043b\u0430\u0441\u0441\u044b \u0441 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f\u043c\u0438 \u0434\u043b\u044f MVC (MvcConfig) \u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 (WebSecurityConfig);<\/li>\n<li><b>src\\main\\java\\com\\boots\\controller<\/b> \u2014 \u043a\u043b\u0430\u0441\u0441\u044b \u0441 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430\u043c\u0438;<\/li>\n<li><b>src\\main\\java\\com\\boots\\entity<\/b> \u2014 \u043a\u043b\u0430\u0441\u0441\u044b \u0441 \u043c\u043e\u0434\u0435\u043b\u044f\u043c\u0438;<\/li>\n<li><b>src\\main\\java\\com\\boots\\repository<\/b> \u2014 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u0432;<\/li>\n<li><b>src\\main\\java\\com\\boots\\service<\/b> \u2014 \u043a\u043b\u0430\u0441\u0441\u044b c \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c\u0438 \u0434\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0435\u0439;<\/li>\n<li><b>src\\main\\webapp\\resources<\/b> \u2014 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b: js, css, img;<\/li>\n<li><b>src\\main\\webapp\\WEB-INF\\jsp<\/b> \u2014 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432 \u0432\u0438\u0434\u0435 \u0444\u0430\u0439\u043b\u043e\u0432 .jsp.<\/li>\n<\/ul>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0444\u0430\u0439\u043b <b>pom.xml<\/b>. \u0412 \u044d\u0442\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0444\u0430\u0439\u043b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0435\u0433\u0430 <b>parent<\/b>, \u0442.\u043e. \u0432\u0441\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044f \u0431\u0443\u0434\u0443\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b \u0432 \u044d\u0442\u043e\u0442 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u0444\u0430\u0439\u043b. <\/p>\n<pre><code class=\"xml\">&lt;parent&gt;     &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;     &lt;artifactId&gt;spring-boot-starter-parent&lt;\/artifactId&gt;     &lt;version&gt;2.1.9.RELEASE&lt;\/version&gt; &lt;\/parent&gt; <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043c\u043e\u0434\u0443\u043b\u0435\u0439 Spring, \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u0411\u0414 PostgreSQL, \u0441\u0435\u0440\u0432\u0435\u0440\u0430 Tomcat, JSTL.<\/p>\n<pre><code class=\"xml\">&lt;properties&gt;     &lt;java.version&gt;1.8&lt;\/java.version&gt; &lt;\/properties&gt; <\/code><\/pre>\n<p>  \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e maven \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u0440\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e java 1.6, \u0447\u0442\u043e\u0431\u044b \u044d\u0442\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0432\u0435\u0440\u0441\u0438\u044e \u044f\u0432\u043d\u043e.<\/p>\n<pre><code class=\"xml\">&lt;dependencies&gt;     &lt;dependency&gt;         &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;         &lt;artifactId&gt;spring-boot-starter-web&lt;\/artifactId&gt;     &lt;\/dependency&gt;     &lt;dependency&gt;         &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;         &lt;artifactId&gt;spring-boot-starter-security&lt;\/artifactId&gt;     &lt;\/dependency&gt;     &lt;dependency&gt;         &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;         &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;\/artifactId&gt;     &lt;\/dependency&gt;     &lt;dependency&gt;         &lt;groupId&gt;org.postgresql&lt;\/groupId&gt;         &lt;artifactId&gt;postgresql&lt;\/artifactId&gt;         &lt;version&gt;42.2.8&lt;\/version&gt;         &lt;scope&gt;runtime&lt;\/scope&gt;     &lt;\/dependency&gt;     &lt;dependency&gt;         &lt;groupId&gt;javax.servlet&lt;\/groupId&gt;         &lt;artifactId&gt;jstl&lt;\/artifactId&gt;         &lt;version&gt;1.2&lt;\/version&gt;     &lt;\/dependency&gt;     &lt;dependency&gt;         &lt;groupId&gt;org.apache.tomcat.embed&lt;\/groupId&gt;         &lt;artifactId&gt;tomcat-embed-jasper&lt;\/artifactId&gt;         &lt;version&gt;9.0.27&lt;\/version&gt;     &lt;\/dependency&gt;     &lt;dependency&gt;         &lt;groupId&gt;org.springframework.security&lt;\/groupId&gt;         &lt;artifactId&gt;spring-security-taglibs&lt;\/artifactId&gt;         &lt;version&gt;5.2.0.RELEASE&lt;\/version&gt;     &lt;\/dependency&gt; &lt;\/dependencies&gt; <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u043b\u0430\u0433\u0438\u043d, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u0443\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0430\u0440\u0445\u0438\u0432\u044b jar \u0438\u043b\u0438 war \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0438\u0445 \u00ab\u043d\u0430 \u043c\u0435\u0441\u0442\u0435\u00bb:<\/p>\n<pre><code class=\"xml\">&lt;build&gt;     &lt;plugins&gt;         &lt;plugin&gt;             &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;             &lt;artifactId&gt;spring-boot-maven-plugin&lt;\/artifactId&gt;         &lt;\/plugin&gt;     &lt;\/plugins&gt; &lt;\/build&gt; <\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u043b\u043d\u044b\u0439 pom.xml<\/b><\/p>\n<div class=\"spoiler_text\">\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;groupId&gt;ark&lt;\/groupId&gt;     &lt;artifactId&gt;spring&lt;\/artifactId&gt;     &lt;version&gt;1.0-SNAPSHOT&lt;\/version&gt;      &lt;parent&gt;         &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;         &lt;artifactId&gt;spring-boot-starter-parent&lt;\/artifactId&gt;         &lt;version&gt;2.1.6.RELEASE&lt;\/version&gt;     &lt;\/parent&gt;      &lt;dependencies&gt;         &lt;dependency&gt;             &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;             &lt;artifactId&gt;spring-boot-starter-web&lt;\/artifactId&gt;         &lt;\/dependency&gt;         &lt;dependency&gt;             &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;             &lt;artifactId&gt;spring-boot-starter-security&lt;\/artifactId&gt;         &lt;\/dependency&gt;         &lt;dependency&gt;             &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;             &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;\/artifactId&gt;         &lt;\/dependency&gt;         &lt;dependency&gt;             &lt;groupId&gt;org.postgresql&lt;\/groupId&gt;             &lt;artifactId&gt;postgresql&lt;\/artifactId&gt;             &lt;scope&gt;runtime&lt;\/scope&gt;         &lt;\/dependency&gt;         &lt;dependency&gt;             &lt;groupId&gt;javax.servlet&lt;\/groupId&gt;             &lt;artifactId&gt;jstl&lt;\/artifactId&gt;             &lt;version&gt;1.2&lt;\/version&gt;         &lt;\/dependency&gt;         &lt;dependency&gt;             &lt;groupId&gt;org.apache.tomcat.embed&lt;\/groupId&gt;             &lt;artifactId&gt;tomcat-embed-jasper&lt;\/artifactId&gt;             &lt;version&gt;9.0.27&lt;\/version&gt;         &lt;\/dependency&gt;         &lt;dependency&gt;             &lt;groupId&gt;org.springframework.security&lt;\/groupId&gt;             &lt;artifactId&gt;spring-security-taglibs&lt;\/artifactId&gt;             &lt;version&gt;5.2.0.RELEASE&lt;\/version&gt;         &lt;\/dependency&gt;           &lt;dependency&gt;             &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;             &lt;artifactId&gt;spring-boot-devtools&lt;\/artifactId&gt;         &lt;\/dependency&gt;     &lt;\/dependencies&gt;      &lt;properties&gt;         &lt;java.version&gt;1.8&lt;\/java.version&gt;     &lt;\/properties&gt;      &lt;build&gt;         &lt;plugins&gt;             &lt;plugin&gt;                 &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;                 &lt;artifactId&gt;spring-boot-maven-plugin&lt;\/artifactId&gt;             &lt;\/plugin&gt;         &lt;\/plugins&gt;     &lt;\/build&gt;  &lt;\/project&gt; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0417\u0430\u043f\u043e\u043b\u043d\u0438\u043c \u0444\u0430\u0439\u043b <b>application.properties<\/b>. \u041f\u0435\u0440\u0432\u044b\u0435 3 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u0411\u0414 (\u0438\u043c\u044f \u0411\u0414 \u2013 \u00abspring\u00bb, \u043b\u043e\u0433\u0438\u043d \u0438 \u043f\u0430\u0440\u043e\u043b\u044c). \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 2 \u0441\u0442\u0440\u043e\u043a\u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043f\u0443\u0442\u044c \u043a .jsp \u0444\u0430\u0439\u043b\u0430\u043c:  <\/p>\n<pre><code class=\"xml\">spring.datasource.url=jdbc:postgresql:\/\/localhost\/spring spring.datasource.username=postgres spring.datasource.password=password spring.jpa.show-sql=true spring.jpa.generate-ddl=false spring.jpa.hibernate.ddl-auto=update spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true  spring.mvc.view.prefix = \/WEB-INF\/jsp\/ spring.mvc.view.suffix = .jsp <\/code><\/pre>\n<p>  \u0421\u0432\u043e\u0439\u0441\u0442\u0432\u043e <b>spring.jpa.show-sql<\/b> \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0442\u0435\u043b\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a \u0411\u0414 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c. <br \/>  <b>spring.jpa.hibernate.ddl-auto<\/b> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u0434\u0430\u0442\u044c \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044e \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0411\u0414 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043d\u0430\u0448\u0438\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439, \u0438\u043c\u0435\u0435\u0442 \u0440\u0430\u0437\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f (none, create, update \u0438 \u0434\u0440.). <b>update <\/b> \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0411\u0414 \u0438 \u043f\u043e\u043b\u044f \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u044b \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043d\u0430\u0448\u0438\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0438 \u0431\u0443\u0434\u0443 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043d\u0438\u043c\u0438.<\/p>\n<p>  \u0417\u0430\u0431\u0435\u0433\u0430\u044f \u0432\u043f\u0435\u0440\u0435\u0434 \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0411\u0414 \u0441 \u0438\u043c\u0435\u043d\u0435\u043c <b>spring<\/b>, \u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u0440\u043e\u043b\u0435\u0439 \u0438 \u0438\u0445 \u0441\u0432\u044f\u0437\u0443\u044e\u0449\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0432\u043d\u0435\u0448\u043d\u0438\u043c\u0438 \u043a\u043b\u044e\u0447\u0430\u043c\u0438 \u0431\u0443\u0434\u0443\u0442 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 (\u043f\u0430\u043a\u0435\u0442 entity), \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u044b \u0441\u0435\u0439\u0447\u0430\u0441 \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c.<\/p>\n<h3>4. \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439, \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432, \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432, \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u0432 \u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0439<\/h3>\n<p>  <\/p>\n<h4>4.1. \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 (\u043c\u043e\u0434\u0435\u043b\u0435\u0439)<\/h4>\n<p>  <i><b>\u041e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435<\/b> \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439: \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0435 \u043f\u043e\u043b\u044f, \u0433\u0435\u0442\u0442\u0435\u0440\u044b \u0438 \u0441\u0435\u0442\u0442\u0435\u0440\u044b \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u0435\u0439 \u0438 \u043f\u0443\u0441\u0442\u043e\u0439 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 (\u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u043d\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b). \u0418\u0445 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0432\u0440\u0443\u0447\u043d\u0443\u044e, \u043d\u0430\u0436\u043c\u0438\u0442\u0435 <b>Alt+Insert<\/b> \u0438 Idea \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u044d\u0442\u043e \u0437\u0430 \u0432\u0430\u0441.<\/p>\n<p>  \u0414\u043b\u044f \u0438\u043c\u043f\u043e\u0440\u0442\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u044e \u043a\u043b\u0430\u0432\u0438\u0448 <b>Alt+Enter<\/b>.<br \/>  <\/i><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ui\/kj\/rb\/uikjrbx43srmtyfybki9eesdyma.png\"\/><\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">User<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"java\">@Entity @Table(name = &quot;t_user&quot;) public class User implements UserDetails {     @Id     @GeneratedValue(strategy = GenerationType.IDENTITY)     private Long id;     @Size(min=2, message = &quot;\u041d\u0435 \u043c\u0435\u043d\u044c\u0448\u0435 5 \u0437\u043d\u0430\u043a\u043e\u0432&quot;)     private String username;     @Size(min=2, message = &quot;\u041d\u0435 \u043c\u0435\u043d\u044c\u0448\u0435 5 \u0437\u043d\u0430\u043a\u043e\u0432&quot;)     private String password;     @Transient     private String passwordConfirm;     @ManyToMany(fetch = FetchType.EAGER)     private Set&lt;Role&gt; roles;      public User() {     }      public Long getId() {         return id;     }      public void setId(Long id) {         this.id = id;     }      @Override     public String getUsername() {         return username;     }      @Override     public boolean isAccountNonExpired() {         return true;     }      @Override     public boolean isAccountNonLocked() {         return true;     }      @Override     public boolean isCredentialsNonExpired() {         return true;     }      @Override     public boolean isEnabled() {         return true;     }      public void setUsername(String username) {         this.username = username;     }      @Override     public Collection&lt;? extends GrantedAuthority&gt; getAuthorities() {         return getRoles();     }      @Override     public String getPassword() {         return password;     }      public void setPassword(String password) {         this.password = password;     }      public String getPasswordConfirm() {         return passwordConfirm;     }      public void setPasswordConfirm(String passwordConfirm) {         this.passwordConfirm = passwordConfirm;     }      public Set&lt;Role&gt; getRoles() {         return roles;     }      public void setRoles(Set&lt;Role&gt; roles) {         this.roles = roles;     } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <b>User.<\/b> \u0412 \u043d\u0430\u0447\u0430\u043b\u0435 \u043e\u0431 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f\u0445: <b>Entity<\/b> \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u043e\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0430 \u0438\u043c\u0435\u044e\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u0411\u0414, <b>Table(name = \u00abt_user\u00bb)<\/b> \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0441 \u043a\u0430\u043a\u043e\u0439 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439. <\/p>\n<p>  <b>GenerationType.IDENTITY<\/b> \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 IDENTITY \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0435\u0439 id \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f \u0411\u0414. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438. SEQUENCE \u2013 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u0432 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a PostgreSQL \u0438\u043b\u0438 Oracle, \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 (sequence). TABLE \u2013 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0441 \u043f\u0440\u043e\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u043a\u043b\u044e\u0447\u0435\u0439. \u0415\u0449\u0435 \u043e\u0434\u0438\u043d \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u2013 AUTO, hibernate \u0441\u0430\u043c \u0432\u044b\u0431\u0435\u0440\u0435\u0442 \u0438\u0437 \u043e\u0434\u043d\u0443 \u0432\u044b\u0448\u0435\u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0439, \u043d\u043e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044e \u044f\u0432\u043d\u043e.<\/p>\n<p>  \u041f\u043e\u043b\u0435, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0435\u0435\u0441\u044f \u043f\u043e\u0434 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0435\u0439 <b>Transient<\/b>, \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u0411\u0414. \u0421\u043f\u0438\u0441\u043e\u043a \u0440\u043e\u043b\u0435\u0439 \u0441\u0432\u044f\u0437\u0430\u043d \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435\u043c \u043c\u043d\u043e\u0433\u0438\u0435 \u043a\u043e \u043c\u043d\u043e\u0433\u0438\u043c (\u043e\u0434\u0438\u043d \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u043e\u043b\u0435\u0439 \u0441 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0438 \u0443 \u043e\u0434\u043d\u043e\u0439 \u0440\u043e\u043b\u0438 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0441 \u0434\u0440\u0443\u0433\u043e\u0439);<b>FetchType.EAGER<\/b> \u2013 \u00ab\u0436\u0430\u0434\u043d\u0430\u044f\u00bb \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430, \u0442.\u0435. \u0441\u043f\u0438\u0441\u043e\u043a \u0440\u043e\u043b\u0435\u0439 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442\u0441\u044f \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u0441\u0440\u0430\u0437\u0443 (\u043d\u0435 \u0436\u0434\u0435\u0442 \u043f\u043e\u043a\u0430 \u043a \u043d\u0435\u043c\u0443 \u043e\u0431\u0440\u0430\u0442\u044f\u0442\u0441\u044f).<\/p>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441 <b>User<\/b>\u0432 Spring Security, \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <b>UserDetails<\/b>. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0432\u0441\u0435 \u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u044b. \u041d\u043e \u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0442\u043e\u0434 <b>getAuthorities()<\/b>, \u043e\u043d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0440\u043e\u043b\u0435\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 <b>true<\/b>.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Role<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"java\">@Entity @Table(name = &quot;t_role&quot;) public class Role implements GrantedAuthority {     @Id     private Long id;     private String name;     @Transient     @ManyToMany(mappedBy = &quot;roles&quot;)     private Set&lt;User&gt; users;     public Role() {     }      public Role(Long id) {         this.id = id;     }      public Role(Long id, String name) {         this.id = id;         this.name = name;     }      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 Set&lt;User&gt; getUsers() {         return users;     }      public void setUsers(Set&lt;User&gt; users) {         this.users = users;     }      @Override     public String getAuthority() {         return getName();     } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <b>Role.<\/b> \u042d\u0442\u043e\u0442 \u043a\u043b\u0430\u0441\u0441 \u0434\u043e\u043b\u0436\u0435\u043d \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <b>GrantedAuthority<\/b>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u043c\u0435\u0442\u043e\u0434 <b>getAuthority()<\/b> (\u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u043c\u044f \u0440\u043e\u043b\u0438). \u0418\u043c\u044f \u0440\u043e\u043b\u0438 \u0434\u043e\u043b\u0436\u043d\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0448\u0430\u0431\u043b\u043e\u043d\u0443: \u00abROLE_\u0418\u041c\u042f\u00bb, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <b>ROLE_USER<\/b>. \u041a\u0440\u043e\u043c\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0449\u0435 \u043f\u0430\u0440\u0443 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0445 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u0432: \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e id, \u0432\u0442\u043e\u0440\u043e\u0439 id \u0438 name.<\/p>\n<p>  \u0417\u0434\u0435\u0441\u044c \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u043f\u043e\u043b\u044f. <b>Size(min=2)<\/b> \u2013 \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0434\u043b\u0438\u043d\u0430 \u043f\u043e\u043b\u044f 2, \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0441\u043b\u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0432\u0435\u0434\u0435\u043d\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435.<\/p>\n<h4>4.2. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u043b\u043e\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0434\u0430\u043d\u043d\u044b\u043c \u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u044f<\/h4>\n<p>  Spring Data \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u0431\u043e\u0440 \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u043b\u043e\u044f, \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044e\u0449\u0435\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0411\u0414. \u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <b>JpaRepository <\/b>\u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u0431\u043e\u0440 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 (findBy, save, deleteById \u0438 \u0434\u0440.) \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0411\u0414.<\/p>\n<p>  <b>UserRepository.<\/b> \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u043f\u0430\u043a\u0435\u0442\u0435 repository \u0438 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u043c <b>JpaRepository&lt;User, Long&gt;<\/b>, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043a\u043b\u0430\u0441\u0441 <b>User <\/b>\u0438 \u0442\u0438\u043f \u0435\u0433\u043e id \u2014 <b>Long<\/b>.<\/p>\n<pre><code class=\"java\">public interface UserRepository extends JpaRepository&lt;User, Long&gt; {     User findByUsername(String username); } <\/code><\/pre>\n<p>  \u0422.\u043e. \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0432 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0438 \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0432 <b>JpaRepository <\/b>\u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a \u0411\u0414. \u0415\u0441\u043b\u0438 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u0433\u043e \u0432 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043e\u043f\u0438\u0440\u0430\u044f\u0441\u044c \u043d\u0430 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0438 Idea. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u043c\u0435\u0442\u043e\u0434 \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u0411\u0414 \u043f\u043e \u0438\u043c\u0435\u043d\u0438. \u041f\u0438\u0448\u0435\u043c \u0442\u0438\u043f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u0430 \u0437\u0430\u0442\u0435\u043c IDE \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b. \u0422.\u0435. \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u043c\u044f \u043c\u0435\u0442\u043e\u0434\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442, \u0442\u0435\u043b\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ia\/1r\/b-\/ia1rb-sfptgoogvuh1n4gqibh4g.png\"\/><\/p>\n<p>  \u041f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e <b>Query<\/b> \u043d\u0430\u0434 \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u0438 \u043f\u0438\u0441\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043d\u0430 HQL \u0438\u043b\u0438 SQL (\u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c nativeQuery = true).<\/p>\n<pre><code class=\"java\">@Query(value = &quot;SELECT nextval(pg_get_serial_sequence('t_user', 'id'))&quot;, nativeQuery = true)     Long getNextId(); <\/code><\/pre>\n<p>  <b>RoleRepository.<\/b> \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0442\u0443\u0442 \u043d\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f.<\/p>\n<pre><code class=\"java\">public interface RoleRepository extends JpaRepository&lt;Role, Long&gt; { } <\/code><\/pre>\n<p>  <b>UserService.<\/b> \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u042d\u0442\u043e\u0442 \u043a\u043b\u0430\u0441\u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <b>UserDetailsService<\/b> (\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0434\u043b\u044f Spring Security), \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043e\u0434\u0438\u043d \u043c\u0435\u0442\u043e\u0434 <b>loadUserByUsername()<\/b>.<\/p>\n<p>  \u0412 \u044d\u0442\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435 \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0441\u043f\u043e\u0441\u043e\u0431 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f SQL \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u2014 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e EntityManager.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">UserService<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"java\">@Service public class UserService implements UserDetailsService {     @PersistenceContext     private EntityManager em;     @Autowired     UserRepository userRepository;     @Autowired     RoleRepository roleRepository;     @Autowired     BCryptPasswordEncoder bCryptPasswordEncoder;      @Override     public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {         User user = userRepository.findByUsername(username);          if (user == null) {             throw new UsernameNotFoundException(&quot;User not found&quot;);         }          return user;     }      public User findUserById(Long userId) {         Optional&lt;User&gt; userFromDb = userRepository.findById(userId);         return userFromDb.orElse(new User());     }      public List&lt;User&gt; allUsers() {         return userRepository.findAll();     }      public boolean saveUser(User user) {         User userFromDB = userRepository.findByUsername(user.getUsername());          if (userFromDB != null) {             return false;         }          user.setRoles(Collections.singleton(new Role(1L, &quot;ROLE_USER&quot;)));         user.setPassword(bCryptPasswordEncoder.encode(user.getPassword()));         userRepository.save(user);         return true;     }      public boolean deleteUser(Long userId) {         if (userRepository.findById(userId).isPresent()) {             userRepository.deleteById(userId);             return true;         }         return false;     }      public List&lt;User&gt; usergtList(Long idMin) {         return em.createQuery(&quot;SELECT u FROM User u WHERE u.id &gt; :paramId&quot;, User.class)                 .setParameter(&quot;paramId&quot;, idMin).getResultList();     } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043c\u0435\u0442\u043e\u0434 <b>saveUser(User user)<\/b>. <\/p>\n<pre><code class=\"java\">public boolean saveUser(User user) {         User userFromDB = userRepository.findByUsername(user.getUsername());          if (userFromDB != null) {             return false;         }          user.setRoles(Collections.singleton(new Role(1L, &quot;ROLE_USER&quot;)));         user.setPassword(bCryptPasswordEncoder.encode(user.getPassword()));         userRepository.save(user);         return true;     } <\/code><\/pre>\n<p>  \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0438\u0441\u043a \u0432 \u0411\u0414 \u043f\u043e \u0438\u043c\u0435\u043d\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0441 \u0442\u0430\u043a\u0438\u043c \u0438\u043c\u0435\u043d\u0435\u043c \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443. \u0415\u0441\u043b\u0438 \u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0435 \u0437\u0430\u043d\u044f\u0442\u043e, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u043e\u043b\u044c ROLE_USER. \u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043f\u0430\u0440\u043e\u043b\u044c \u0432 \u00ab\u0441\u044b\u0440\u043e\u043c\u00bb \u0432\u0438\u0434\u0435 \u043e\u043d \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0445\u044d\u0448\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <b>bCryptPasswordEncoder<\/b>. \u0417\u0430\u0442\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u0411\u0414.<\/p>\n<h4>4.3. \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432 <\/h4>\n<p>  \u0414\u043b\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c, \u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443, \u043c\u0430\u043f\u043f\u0438\u043d\u0433 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438. \u0421\u0442\u0440\u0430\u043d\u0438\u0446\u0430 <b>login<\/b> \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f Spring Security \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u043c \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u043d\u0435\u0451 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f.<\/p>\n<pre><code class=\"java\">@Configuration public class MvcConfig implements WebMvcConfigurer {      @Override     public void addViewControllers(ViewControllerRegistry registry) {         registry.addViewController(&quot;\/login&quot;).setViewName(&quot;login&quot;);         registry.addViewController(&quot;\/news&quot;).setViewName(&quot;news&quot;);     } } <\/code><\/pre>\n<p>  <b>RegistrationController.<\/b> \u041e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438. \u0414\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 GET \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f <b>@GetMapping(&quot;\/registration&quot;)<\/b>, \u0434\u043b\u044f POST \u2013 <b>@PostMapping(&quot;\/registration&quot;)<\/b>.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">RegistrationController<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"java\">@Controller public class RegistrationController {      @Autowired     private UserService userService;      @GetMapping(&quot;\/registration&quot;)     public String registration(Model model) {         model.addAttribute(&quot;userForm&quot;, new User());          return &quot;registration&quot;;     }      @PostMapping(&quot;\/registration&quot;)     public String addUser(@ModelAttribute(&quot;userForm&quot;) @Valid User userForm, BindingResult bindingResult, Model model) {          if (bindingResult.hasErrors()) {             return &quot;registration&quot;;         }         if (!userForm.getPassword().equals(userForm.getPasswordConfirm())){             model.addAttribute(&quot;passwordError&quot;, &quot;\u041f\u0430\u0440\u043e\u043b\u0438 \u043d\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442&quot;);             return &quot;registration&quot;;         }         if (!userService.saveUser(userForm)){             model.addAttribute(&quot;usernameError&quot;, &quot;\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0441 \u0442\u0430\u043a\u0438\u043c \u0438\u043c\u0435\u043d\u0435\u043c \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442&quot;);             return &quot;registration&quot;;         }          return &quot;redirect:\/&quot;;     } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0447\u0442\u043e-\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0438\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043c\u044b \u043e\u0431\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043a model. \u0412 GET \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u043f\u0443\u0441\u0442\u043e\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 <b>User<\/b>. \u042d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438 POST \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u043d\u0435 \u0434\u043e\u0441\u0442\u0430\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0444\u043e\u0440\u043c\u044b \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 (username, password, passwordComfirm), \u0430 \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 userForm.<\/p>\n<p>  \u041c\u0435\u0442\u043e\u0434 <b>addUser()<\/b> \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043e\u0436\u0438\u0434\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f (userForm), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b\u043b \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u043f\u0440\u0438 GET \u0437\u0430\u043f\u0440\u043e\u0441\u0435. \u0410\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f <b>Valid<\/b> \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u043b\u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u043d\u0430 \u043f\u043e\u043b\u044f, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0434\u043b\u0438\u043d\u0430 \u043d\u0435 \u043c\u0435\u043d\u044c\u0448\u0435 2 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432. \u0415\u0441\u043b\u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043d\u0435 \u0431\u044b\u043b\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u044b, \u0442\u043e <b>bindingResult<\/b> \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438. <\/p>\n<p>  \u0415\u0441\u043b\u0438 \u043f\u0430\u0440\u043e\u043b\u044c \u0438 \u0435\u0433\u043e \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435 \u043d\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0435\u0451. \u0412 \u043a\u043e\u043d\u0446\u0435 \u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u0411\u0414. <\/p>\n<p>  \u041c\u0435\u0442\u043e\u0434 <b>saveUser()<\/b> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 false, \u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0441 \u0442\u0430\u043a\u0438\u043c \u0438\u043c\u0435\u043d\u0435\u043c \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0438 true, \u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d \u0432 \u0411\u0414. \u041f\u0440\u0438 \u043d\u0435\u0443\u0434\u0430\u0447\u043d\u043e\u0439 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u2013 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443. \u041f\u0440\u0438 \u0443\u0434\u0430\u0447\u043d\u043e\u043c \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u2013 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043d\u0430 \u0433\u043b\u0430\u0432\u043d\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443.<\/p>\n<p>  <b>AdminController.<\/b> \u0414\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 admin \u0438\u043c\u0435\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0441 \u0440\u043e\u043b\u044c\u044e \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430. \u0412 \u043c\u0435\u0442\u043e\u0434\u0435 <b>userList()<\/b> \u043d\u0435\u0442 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u043e\u0432\u043e\u0433\u043e, \u043e\u043d \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0445 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">AdminController<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"java\">@Controller public class AdminController {     @Autowired     private UserService userService;      @GetMapping(&quot;\/admin&quot;)     public String userList(Model model) {         model.addAttribute(&quot;allUsers&quot;, userService.allUsers());         return &quot;admin&quot;;     }      @PostMapping(&quot;\/admin&quot;)     public String  deleteUser(@RequestParam(required = true, defaultValue = &quot;&quot; ) Long userId,                               @RequestParam(required = true, defaultValue = &quot;&quot; ) String action,                               Model model) {         if (action.equals(&quot;delete&quot;)){             userService.deleteUser(userId);         }         return &quot;redirect:\/admin&quot;;     }      @GetMapping(&quot;\/admin\/gt\/{userId}&quot;)     public String  gtUser(@PathVariable(&quot;userId&quot;) Long userId, Model model) {         model.addAttribute(&quot;allUsers&quot;, userService.usergtList(userId));         return &quot;admin&quot;;     } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041c\u0435\u0442\u043e\u0434 <b>deleteUser()<\/b> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e <b>RequestParam<\/b> \u0442.\u0435. \u0432 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u0444\u043e\u0440\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u043e\u043b\u0436\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0434\u0432\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u2013 userId \u0438 action. \u0421\u0441\u044b\u043b\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0432\u0438\u0434 <a href=\"http:\/\/localhost:8080\/admin?userId=24&amp;action=delete\">http:\/\/localhost:8080\/admin?userId=24&#038;action=delete<\/a> \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0442\u0430\u043a\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0431\u0443\u0434\u0435\u0442 \u0443\u0434\u0430\u043b\u0435\u043d \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0441 id=24.<\/p>\n<p>  \u0415\u0449\u0435 \u043e\u0434\u0438\u043d \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0432 URL \u2013 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <b>PathVariable<\/b>. \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u0442\u043e\u0439 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0447\u0430\u0441\u0442\u0438 URL, \u0434\u043b\u044f \u043c\u0435\u0442\u043e\u0434 <b>getUser()<\/b> URL \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c: <a href=\"http:\/\/localhost:8080\/admin\/gt\/24\">http:\/\/localhost:8080\/admin\/gt\/24<\/a>, \u043f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u0432\u044b\u0432\u0435\u0434\u0435\u0442\u0441\u044f \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0441 id&gt;24.<\/p>\n<p>  <b>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438<\/b><\/p>\n<p>  <b>WebSecurityConfig.<\/b> \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u0442 2 \u0431\u0438\u043d\u0430 <b>BCryptPasswordEncoder<\/b> \u0438 <b>AuthenticationManager<\/b>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435, \u0443\u0436\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u043b\u0438\u0441\u044c \u0440\u0430\u043d\u0435\u0435 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 userService.<br \/>  \u041a\u0440\u043e\u043c\u0435 \u044d\u0442\u043e\u0433\u043e \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <b>configure()<\/b> \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c \u0441\u0430\u0439\u0442\u0430. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 <b>antMatchers()<\/b> \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u043f\u0443\u0442\u0438, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0445\u043e\u0442\u0438\u043c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435. \u0417\u0430\u0442\u0435\u043c \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c \u0441 \u043a\u0430\u043a\u043e\u0439 \u0440\u043e\u043b\u044c\u044e \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u044d\u0442\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\/\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">WebSecurityConfig<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"java\">@Configuration @EnableWebSecurity public class WebSecurityConfig extends WebSecurityConfigurerAdapter {     @Autowired     UserService userService;      @Bean     public BCryptPasswordEncoder bCryptPasswordEncoder() {         return new BCryptPasswordEncoder();     }      @Override     protected void configure(HttpSecurity httpSecurity) throws Exception {         httpSecurity                 .csrf()                     .disable()                 .authorizeRequests()                     \/\/\u0414\u043e\u0441\u0442\u0443\u043f \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043d\u0435 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439                     .antMatchers(&quot;\/registration&quot;).not().fullyAuthenticated()                     \/\/\u0414\u043e\u0441\u0442\u0443\u043f \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0441 \u0440\u043e\u043b\u044c\u044e \u0410\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440                     .antMatchers(&quot;\/admin\/**&quot;).hasRole(&quot;ADMIN&quot;)                     .antMatchers(&quot;\/news&quot;).hasRole(&quot;USER&quot;)                     \/\/\u0414\u043e\u0441\u0442\u0443\u043f \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d \u0432\u0441\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439                     .antMatchers(&quot;\/&quot;, &quot;\/resources\/**&quot;).permitAll()                 \/\/\u0412\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438                 .anyRequest().authenticated()                 .and()                     \/\/\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0434\u043b\u044f \u0432\u0445\u043e\u0434\u0430 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443                     .formLogin()                     .loginPage(&quot;\/login&quot;)                     \/\/\u041f\u0435\u0440\u0435\u043d\u0430\u0440\u043f\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u0430 \u0433\u043b\u0430\u0432\u043d\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u043f\u043e\u0441\u043b\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0433\u043e \u0432\u0445\u043e\u0434\u0430                     .defaultSuccessUrl(&quot;\/&quot;)                     .permitAll()                 .and()                     .logout()                     .permitAll()                     .logoutSuccessUrl(&quot;\/&quot;);     }      @Autowired     protected void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {         auth.userDetailsService(userService).passwordEncoder(bCryptPasswordEncoder());     } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<h4>4.4. \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0439<\/h4>\n<p>  <b>index.jsp<\/b> \u0413\u043b\u0430\u0432\u043d\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430, \u043d\u0438\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b 2 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u2014 \u0434\u043b\u044f \u0433\u043e\u0441\u0442\u044f \u0438 \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/td\/f_\/rb\/tdf_rbnrq5zmuwkpzi1izzf5xfu.png\"\/><\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/bt\/7z\/mh\/bt7zmh7dlr01k6jpse3bahvrc14.png\"\/><\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">index.jsp<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"xml\">&lt;%@ taglib prefix=&quot;c&quot; uri=&quot;http:\/\/java.sun.com\/jsp\/jstl\/core&quot; %&gt; &lt;%@ taglib prefix=&quot;sec&quot; uri=&quot;http:\/\/www.springframework.org\/security\/tags&quot; %&gt; &lt;%@ page language=&quot;java&quot; contentType=&quot;text\/html; charset=utf-8&quot; pageEncoding=&quot;utf-8&quot;%&gt;  &lt;!DOCTYPE HTML&gt; &lt;html&gt; &lt;head&gt;   &lt;title&gt;\u0413\u043b\u0430\u0432\u043d\u0430\u044f&lt;\/title&gt;   &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text\/html; charset=UTF-8&quot;\/&gt;   &lt;link rel=&quot;stylesheet&quot; type=&quot;text\/css&quot; href=&quot;${contextPath}\/resources\/css\/style.css&quot;&gt; &lt;\/head&gt; &lt;body&gt; &lt;div&gt;   &lt;h3&gt;${pageContext.request.userPrincipal.name}&lt;\/h3&gt;   &lt;sec:authorize access=&quot;!isAuthenticated()&quot;&gt;     &lt;h4&gt;&lt;a href=&quot;\/login&quot;&gt;\u0412\u043e\u0439\u0442\u0438&lt;\/a&gt;&lt;\/h4&gt;     &lt;h4&gt;&lt;a href=&quot;\/registration&quot;&gt;\u0417\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f&lt;\/a&gt;&lt;\/h4&gt;   &lt;\/sec:authorize&gt;   &lt;sec:authorize access=&quot;isAuthenticated()&quot;&gt;     &lt;h4&gt;&lt;a href=&quot;\/logout&quot;&gt;\u0412\u044b\u0439\u0442\u0438&lt;\/a&gt;&lt;\/h4&gt;   &lt;\/sec:authorize&gt;   &lt;h4&gt;&lt;a href=&quot;\/news&quot;&gt;\u041d\u043e\u0432\u043e\u0441\u0442\u0438 (\u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c)&lt;\/a&gt;&lt;\/h4&gt;   &lt;h4&gt;&lt;a href=&quot;\/admin&quot;&gt;\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 (\u0442\u043e\u043b\u044c\u043a\u043e \u0430\u0434\u043c\u0438\u043d)&lt;\/a&gt;&lt;\/h4&gt; &lt;\/div&gt; &lt;\/body&gt; &lt;\/html&gt; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0414\u043b\u044f \u0441\u043a\u0440\u044b\u0442\u0438\u044f \u0447\u0430\u0441\u0442\u0438 \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 (\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0438 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438) \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u0433 <b>authorize<\/b> \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0442\u0435\u0433\u043e\u0432 Spring Security. \u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 access \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u043c\u043e\u0436\u043d\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0440\u043e\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f <b>hasRole(&#8216;ADMIN&#8217;)<\/b>.<\/p>\n<p>  <b>registration.jsp<\/b> \u0421\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438.<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/bb\/q7\/eb\/bbq7ebi7zzfqlwbur0utiujn2sk.png\"\/><\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">registration.jsp<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"xml\">&lt;%@ taglib prefix=&quot;form&quot; uri=&quot;http:\/\/www.springframework.org\/tags\/form&quot; %&gt; &lt;%@ taglib prefix=&quot;c&quot; uri=&quot;http:\/\/java.sun.com\/jsp\/jstl\/core&quot; %&gt; &lt;%@ page language=&quot;java&quot; contentType=&quot;text\/html; charset=utf-8&quot; pageEncoding=&quot;utf-8&quot;%&gt;  &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt;   &lt;meta charset=&quot;utf-8&quot;&gt;   &lt;title&gt;\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f&lt;\/title&gt; &lt;\/head&gt;  &lt;body&gt; &lt;div&gt;   &lt;form:form method=&quot;POST&quot; modelAttribute=&quot;userForm&quot;&gt;     &lt;h2&gt;\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f&lt;\/h2&gt;     &lt;div&gt;       &lt;form:input type=&quot;text&quot; path=&quot;username&quot; placeholder=&quot;Username&quot;                   autofocus=&quot;true&quot;&gt;&lt;\/form:input&gt;       &lt;form:errors path=&quot;username&quot;&gt;&lt;\/form:errors&gt;         ${usernameError}     &lt;\/div&gt;     &lt;div&gt;       &lt;form:input type=&quot;password&quot; path=&quot;password&quot; placeholder=&quot;Password&quot;&gt;&lt;\/form:input&gt;     &lt;\/div&gt;     &lt;div&gt;       &lt;form:input type=&quot;password&quot; path=&quot;passwordConfirm&quot;                   placeholder=&quot;Confirm your password&quot;&gt;&lt;\/form:input&gt;       &lt;form:errors path=&quot;password&quot;&gt;&lt;\/form:errors&gt;         ${passwordError}     &lt;\/div&gt;     &lt;button type=&quot;submit&quot;&gt;\u0417\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f&lt;\/button&gt;   &lt;\/form:form&gt;   &lt;a href=&quot;\/&quot;&gt;\u0413\u043b\u0430\u0432\u043d\u0430\u044f&lt;\/a&gt; &lt;\/div&gt; &lt;\/body&gt; &lt;\/html&gt;  <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u0435\u0433 form \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0442\u0435\u0433\u043e\u0432, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u0435\u0433\u043e \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0432\u044f\u0437\u043a\u0430 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 userForm (\u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0435\u0433\u043e \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u043f\u0440\u0438 GET \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435) \u0438 \u0444\u043e\u0440\u043c\u044b:<\/p>\n<pre><code class=\"xml\">&lt;form:form method=&quot;POST&quot; modelAttribute=&quot;userForm&quot;&gt; <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0443\u0442\u044c \u0434\u043b\u044f \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 userForm:<\/p>\n<pre><code class=\"xml\">&lt;form:input type=&quot;text&quot; path=&quot;username&quot; placeholder=&quot;Username&quot;&gt;&lt;\/form:input&gt; <\/code><\/pre>\n<p>  <b>login.jsp<\/b> \u0421\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/af\/js\/lv\/afjslvso7xhnhbzdbl2txeh-o04.png\"\/><\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">login.jsp<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"xml\">&lt;%@ taglib prefix=&quot;sec&quot; uri=&quot;http:\/\/www.springframework.org\/security\/tags&quot; %&gt; &lt;%@ page language=&quot;java&quot; contentType=&quot;text\/html; charset=utf-8&quot; pageEncoding=&quot;utf-8&quot;%&gt;  &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt;   &lt;meta charset=&quot;utf-8&quot;&gt;   &lt;title&gt;Log in with your account&lt;\/title&gt; &lt;\/head&gt;  &lt;body&gt; &lt;sec:authorize access=&quot;isAuthenticated()&quot;&gt;   &lt;% response.sendRedirect(&quot;\/&quot;); %&gt; &lt;\/sec:authorize&gt; &lt;div&gt;   &lt;form method=&quot;POST&quot; action=&quot;\/login&quot;&gt;     &lt;h2&gt;\u0412\u0445\u043e\u0434 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443&lt;\/h2&gt;     &lt;div&gt;       &lt;input name=&quot;username&quot; type=&quot;text&quot; placeholder=&quot;Username&quot;              autofocus=&quot;true&quot;\/&gt;       &lt;input name=&quot;password&quot; type=&quot;password&quot; placeholder=&quot;Password&quot;\/&gt;       &lt;button type=&quot;submit&quot;&gt;Log In&lt;\/button&gt;       &lt;h4&gt;&lt;a href=&quot;\/registration&quot;&gt;\u0417\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f&lt;\/a&gt;&lt;\/h4&gt;     &lt;\/div&gt;   &lt;\/form&gt; &lt;\/div&gt;  &lt;\/body&gt; &lt;\/html&gt; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u042d\u0442\u0443 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443, \u043a\u0430\u043a \u0443\u0436\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u043e\u0441\u044c, \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 Spring&#8217;\u0430 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e. \u0412\u0430\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435: <b>action=&quot;\/login&quot;<\/b> \u0438 name \u0438\u043d\u043f\u0443\u0442\u043e\u0432.<\/p>\n<p>  <b>admin.jsp<\/b> \u0421\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/kf\/s8\/uz\/kfs8uz5ja4he06qkklcr0rrxfcc.png\"\/><\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">admin.jsp<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"xml\">&lt;%@ taglib prefix=&quot;c&quot; uri=&quot;http:\/\/java.sun.com\/jsp\/jstl\/core&quot; %&gt; &lt;%@ page language=&quot;java&quot; contentType=&quot;text\/html; charset=utf-8&quot; pageEncoding=&quot;utf-8&quot;%&gt;  &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt;   &lt;meta charset=&quot;utf-8&quot;&gt;   &lt;title&gt;Log in with your account&lt;\/title&gt;   &lt;link rel=&quot;stylesheet&quot; type=&quot;text\/css&quot; href=&quot;${contextPath}\/resources\/css\/style.css&quot;&gt; &lt;\/head&gt;  &lt;body&gt; &lt;div&gt;   &lt;table&gt;     &lt;thead&gt;     &lt;th&gt;ID&lt;\/th&gt;     &lt;th&gt;UserName&lt;\/th&gt;     &lt;th&gt;Password&lt;\/th&gt;     &lt;th&gt;Roles&lt;\/th&gt;     &lt;\/thead&gt;     &lt;c:forEach items=&quot;${allUsers}&quot; var=&quot;user&quot;&gt;       &lt;tr&gt;         &lt;td&gt;${user.id}&lt;\/td&gt;         &lt;td&gt;${user.username}&lt;\/td&gt;         &lt;td&gt;${user.password}&lt;\/td&gt;         &lt;td&gt;           &lt;c:forEach items=&quot;${user.roles}&quot; var=&quot;role&quot;&gt;${role.name}; &lt;\/c:forEach&gt;         &lt;\/td&gt;         &lt;td&gt;           &lt;form action=&quot;${pageContext.request.contextPath}\/admin&quot; method=&quot;post&quot;&gt;             &lt;input type=&quot;hidden&quot; name=&quot;userId&quot; value=&quot;${user.id}&quot;\/&gt;             &lt;input type=&quot;hidden&quot; name=&quot;action&quot; value=&quot;delete&quot;\/&gt;             &lt;button type=&quot;submit&quot;&gt;Delete&lt;\/button&gt;           &lt;\/form&gt;         &lt;\/td&gt;       &lt;\/tr&gt;     &lt;\/c:forEach&gt;   &lt;\/table&gt;   &lt;a href=&quot;\/&quot;&gt;\u0413\u043b\u0430\u0432\u043d\u0430\u044f&lt;\/a&gt; &lt;\/div&gt; &lt;\/body&gt; &lt;\/html&gt;  <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <b>news.jsp<\/b> \u0421\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u043d\u043e\u0432\u043e\u0441\u0442\u0435\u0439 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043f\u0440\u0430\u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435 \u043d\u0430 \u0432\u0430\u0448 \u0432\u044b\u0431\u043e\u0440.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">news.jsp<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"xml\">&lt;%@ taglib prefix=&quot;c&quot; uri=&quot;http:\/\/java.sun.com\/jsp\/jstl\/core&quot; %&gt; &lt;%@ page language=&quot;java&quot; contentType=&quot;text\/html; charset=utf-8&quot; pageEncoding=&quot;utf-8&quot;%&gt;  &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt;     &lt;meta charset=&quot;utf-8&quot;&gt;     &lt;title&gt;\u041d\u043e\u0432\u043e\u0441\u0442\u0438&lt;\/title&gt; &lt;\/head&gt; &lt;body&gt; &lt;div&gt;     &lt;h2&gt;\u041d\u043e\u0432\u043e\u0441\u0442\u0438 &lt;br&gt; \u0422\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0437\u0430\u043b\u043e\u0433\u0438\u043d\u0438\u0432\u0448\u0438\u0445\u0441\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439.&lt;\/h2&gt;     &lt;a href=&quot;\/&quot;&gt;\u0413\u043b\u0430\u0432\u043d\u0430\u044f&lt;\/a&gt; &lt;\/div&gt; &lt;\/body&gt; &lt;\/html&gt; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<h3>5. \u0417\u0430\u043f\u0443\u0441\u043a \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/h3>\n<p>  \u0412 main \u043a\u043b\u0430\u0441\u0441 Application \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code class=\"java\">@SpringBootApplication public class Application {     public static void main(String[] args) {         SpringApplication.run(Application.class, args);     } } <\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u0448\u0430\u0433\u0443, \u0443\u0431\u0435\u0434\u0438\u0442\u0435\u0441\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0439 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435.<\/p>\n<p>  \u041f\u0440\u0438\u0448\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0443\u0441\u0442\u0443\u044e \u0411\u0414 \u0441 \u0438\u043c\u0435\u043d\u0435\u043c <b>spring<\/b>, \u044d\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0434 \u043f\u0435\u0440\u0432\u044b\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437.<\/p>\n<p>  \u041c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u043a\u0430\u043a \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c\u0441\u044f \u0411\u0414 \u2013 \u0432 \u043d\u0435\u0439 \u0441\u043e\u0437\u0434\u0430\u0434\u0443\u0442\u0441\u044f 3 \u043f\u0443\u0441\u0442\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u041d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0440\u043e\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 t_role:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">SQL \u0437\u0430\u043f\u0440\u043e\u0441 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0440\u043e\u043b\u0435\u0439<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">INSERT INTO public.t_role(id, name)   VALUES (1, 'ROLE_USER'), (2, 'ROLE_ADMIN');  <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f. \u0412 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0435 \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0434\u043b\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f-\u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430, \u043d\u043e \u043e\u043d \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0441\u043b\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c-\u0440\u043e\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u044c, \u0434\u0430\u044e\u0449\u0443\u044e \u044d\u0442\u0443 \u0440\u043e\u043b\u044c: <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">SQL \u0437\u0430\u043f\u0440\u043e\u0441 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0440\u043e\u043b\u0438 \u0430\u0434\u043c\u0438\u043d\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">INSERT INTO public.t_user_roles(user_id, roles_id)   VALUES (1, 2); <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/l_\/cq\/lk\/l_cqlktls4qt_1oalbhj_itn3po.png\"\/><\/p>\n<p>  \u0415\u0441\u043b\u0438 \u043f\u043e\u0441\u043b\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0430\u0432 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430 \u0432\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u0439\u0442\u0438 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430 (\u043e\u0448\u0438\u0431\u043a\u0430 403) \u2013 \u043f\u0435\u0440\u0435\u0437\u0430\u0439\u0434\u0438\u0442\u0435 \u043d\u0430 \u0441\u0430\u0439\u0442. <\/p>\n<p>  \u041a \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 <a href=\"http:\/\/localhost:8080\/admin\">http:\/\/localhost:8080\/admin<\/a> \u0434\u043e\u0441\u0442\u0443\u043f \u0438\u043c\u0435\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0441 \u0440\u043e\u043b\u044c\u044e \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430. <a href=\"http:\/\/localhost:8080\/news\">http:\/\/localhost:8080\/news<\/a> \u0443\u0432\u0438\u0434\u0438\u0442 \u043b\u044e\u0431\u043e\u0439 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c. \u0422\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0438 \u043b\u043e\u0433\u0438\u043d\u0430, \u0431\u0443\u0434\u0443\u0447\u0438 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u043d\u0430 \u0441\u0430\u0439\u0442\u0435.<\/p>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>  \u0412 \u0438\u0442\u043e\u0433\u0435 \u0431\u044b\u043b\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u043e \u0432\u0435\u0431 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u043e\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043a \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\u043c \u0441\u0430\u0439\u0442\u0430 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044f \u0440\u043e\u043b\u0438. \u041c\u043e\u0436\u043d\u043e \u043d\u0430\u0437\u043d\u0430\u0447\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u043e\u043b\u0435\u0439 \u043e\u0434\u043d\u043e\u043c\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0431\u0430\u0437\u043e\u0432\u0443\u044e \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0440\u043e\u043b\u044c User, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u043c\u043e\u0436\u0435\u043c \u0434\u0430\u0442\u044c \u0435\u043c\u0443 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u0440\u043e\u043b\u044c Writer, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0435\u043c\u0443 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u043d\u043e\u0432\u043e\u0441\u0442\u0438 \u043d\u0430 \u0441\u0430\u0439\u0442.<\/p>\n<p>  \u0424\u0430\u0439\u043b\u044b css \u0438 js \u0431\u044b\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u044b, \u043d\u043e \u0438\u0445 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043d\u0435 \u0431\u044b\u043b\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043e. \u041f\u0440\u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0434\u0438\u0437\u0430\u0439\u043d, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f Bootstrap \u0438 \u0438\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e js.<\/p>\n<p>  <a href=\"https:\/\/github.com\/Ex3mS1ze\/spring-reg-auth\">\u0421\u043a\u0430\u0447\u0430\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442.<\/a><\/p>\n<h3>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438<\/h3>\n<p>  <\/p>\n<ol>\n<li><a href=\"https:\/\/hellokoding.com\/registration-and-login-example-with-spring-security-spring-boot-spring-data-jpa-hsql-jsp\/\">Registration and Login with Spring Boot, Spring Security, Spring Data JPA, Hibernate, MySQL, JSP, Bootstrap and Docker Compose<\/a><\/li>\n<li><a href=\"https:\/\/habr.com\/ru\/post\/334448\/\">\u041e\u0431\u0440\u0430\u0442\u043d\u0430\u044f \u0441\u0442\u043e\u0440\u043e\u043d\u0430 Spring<\/a><\/li>\n<li><a href=\"https:\/\/ru.wikibooks.org\/wiki\/Spring_Security\/\">Spring Security\/\u0422\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043e\u0431\u0437\u043e\u0440 Spring Security<\/a><\/li>\n<li><a href=\"https:\/\/docs.spring.io\/spring-boot\/docs\/2.2.1.BUILD-SNAPSHOT\/reference\/html\/documentation-overview.html#boot-documentation\">\u041e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f Spring<\/a><\/li>\n<li><a href=\"https:\/\/habr.com\/ru\/post\/111102\/\">\u0423\u0447\u0438\u043c\u0441\u044f \u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c: Spring 3 MVC + Spring Security + Hibernate<\/a><\/li>\n<\/ol>\n<\/div>\n<p>               <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d() } } }t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>      <br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/482552\/\"> https:\/\/habr.com\/ru\/post\/482552\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/482552\/\">\u0414\u043e\u0431\u0440\u044b\u0439 \u0434\u0435\u043d\u044c!<\/p>\n<p>  \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0432\u0435\u0431 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Spring Boot \u0438 Spring Security. \u0412 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043d\u043e\u0432\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f, \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\u043c \u0441\u0430\u0439\u0442\u0430 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0440\u043e\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<br \/>  \u0413\u043b\u0430\u0432\u043d\u0430\u044f \u0446\u0435\u043b\u044c \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\u043c \u0441\u0430\u0439\u0442\u0430 \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0440\u043e\u043b\u044f\u043c\u0438.<\/p>\n<h3>\u0427\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u0437 \u0441\u0435\u0431\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435<\/h3>\n<p>  \u0421\u0430\u0439\u0442 \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\u043c: <\/p>\n<ul>\n<li>\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0432\u0441\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c: \u0433\u043b\u0430\u0432\u043d\u0430\u044f, \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0438 \u043b\u043e\u0433\u0438\u043d\u0430;<\/li>\n<li>\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430\u044f \u0434\u043b\u044f \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439: \u043d\u043e\u0432\u043e\u0441\u0442\u0438;<\/li>\n<li>\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430\u044f \u0434\u043b\u044f \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430.<\/li>\n<\/ul>\n<p>  <\/p>\n<h3>\u0427\u0442\u043e \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c<\/h3>\n<p>  <\/p>\n<ul>\n<li>JDK 8+;<\/li>\n<li>Intellij Idea;<\/li>\n<li>Spring (Spring Boot, Spring MVC, Spring Security);<\/li>\n<li>Hibernate;<\/li>\n<li>JSP;<\/li>\n<li>PostgreSQL.<\/li>\n<\/ul>\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-296635","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/296635","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=296635"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/296635\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=296635"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=296635"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=296635"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}