{"id":361779,"date":"2024-05-21T01:20:52","date_gmt":"2024-05-21T01:20:52","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=361779"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=361779","title":{"rendered":"<span>\u041c\u0438\u0433\u0440\u0438\u0440\u0443\u0435\u043c Java Spring Boot \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 Kotlin<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"bordered full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c86\/576\/f3e\/c86576f3e84b14a62b596a01c883293f.png\" width=\"537\" height=\"240\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c86\/576\/f3e\/c86576f3e84b14a62b596a01c883293f.png\"\/><\/figure>\n<p>\u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e \u0434\u043b\u044f\u00a0\u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0441\u0432\u043e\u0435\u0433\u043e Java \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f (\u0432 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 Spring Boot) \u043d\u0430\u00a0Kotlin. \u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430\u00a0\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e: <a href=\"https:\/\/kotlinlang.ru\/docs\" rel=\"noopener noreferrer nofollow\">Kotlin Docs<\/a> (\u043d\u0430 \u0440\u0443\u0441\u0441\u043a\u043e\u043c \u0441\u0441\u044b\u043b\u043a\u0438 \u043c\u043e\u0436\u043d\u043e <a href=\"https:\/\/kotlinlang.ru\/docs\/\" rel=\"noopener noreferrer nofollow\">\u0437\u0430\u043c\u0435\u043d\u044f\u0442\u044c \u043d\u0430\u00a0&#171;ru&#187;<\/a>,  \u0443 \u043c\u0435\u043d\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0437 VPN).<\/p>\n<h2>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f Gradle\u2011Kotlin \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/h2>\n<ul>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 Gradle\u2011Kotlin \u043f\u0440\u043e\u0435\u043a\u0442: <a href=\"https:\/\/kotlinlang.org\/docs\/jvm-create-project-with-spring-boot.html\" rel=\"noopener noreferrer nofollow\">Create a Spring Boot project with Kotlin<\/a>. <strong>Kts<\/strong> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u043c \u0434\u043b\u044f <a href=\"https:\/\/sebhastian.com\/kotlin-file-extension\/\" rel=\"noopener noreferrer nofollow\">Kotlin \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432<\/a>. \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e: <a href=\"https:\/\/github.com\/spring-guides\/tut-spring-boot-kotlin#understanding-the-gradle-build\" rel=\"noopener noreferrer nofollow\">Understanding the Gradle Build<\/a>.<\/p>\n<\/li>\n<li>\n<p>\u041c\u0435\u043d\u044f\u0435\u043c <a href=\"https:\/\/kotlinlang.org\/docs\/releases.html#release-details\" rel=\"noopener noreferrer nofollow\">\u0432\u0435\u0440\u0441\u0438\u044e Kotlin \u043d\u0430\u00a0\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e<\/a> \u0438 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0430\u0435\u043c\/\u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442<\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0431\u0435\u0437\u00a0\u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u044b <em>src\/main\/resources<\/em> \u0438 <em>src\/test\/resources<\/em> <\/p>\n<\/li>\n<\/ul>\n<h3>\u041c\u0438\u0433\u0440\u0430\u0446\u0438\u044f \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432\/\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432<\/h3>\n<blockquote>\n<p>\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u044b Java \u0432\u00a0Kotlin \u0432\u00a0IDEA \u043c\u043e\u0436\u043d\u043e <a href=\"https:\/\/www.tutorialkart.com\/kotlin\/convert-java-file-to-kotlin-file\" rel=\"noopener noreferrer nofollow\">\u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044e (Ctrl+Alt+Shift+K) \u0438\u043b\u0438\u00a0\u043f\u0440\u043e\u0441\u0442\u043e \u043a\u043e\u043f\u0438\u0440\u0443\u044f Java \u043a\u043e\u0434 \u0432\u00a0Kotlin \u043a\u043b\u0430\u0441\u0441<\/a>. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043e\u0431\u044b\u0447\u043d\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0440\u0443\u0447\u043d\u044b\u0435 \u043f\u0440\u0430\u0432\u043a\u0438.<\/p>\n<\/blockquote>\n<ul>\n<li>\n<p>\u0412\u00a0Kotlin \u0432\u00a0\u043e\u0434\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043f\u043e\u044d\u0442\u043e\u043c\u0443, \u0435\u0441\u043b\u0438 \u043a\u043b\u0430\u0441\u0441\u044b \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0435, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439 \u0438 \u0438\u0445 \u0432\u00a0\u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e, \u0438\u0445 \u043f\u043e\u043c\u0435\u0449\u044f\u044e\u0442 \u0432\u00a0\u043e\u0434\u0438\u043d \u043e\u0431\u0449\u0438\u0439 \u0441 <a href=\"https:\/\/kotlinlang.org\/docs\/coding-conventions.html#source-file-names\" rel=\"noopener noreferrer nofollow\">\u043e\u0431\u043e\u043f\u0449\u0430\u044e\u0449\u0438\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/kotlinlang.org\/docs\/inheritance.html\" rel=\"noopener noreferrer nofollow\">\u041d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0435 \u0438 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b<\/a>, \u0430\u00a0\u043f\u043e\u00a0\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e Kotlin \u043a\u043b\u0430\u0441\u0441\u044b <code>final<\/code>. \u0412\u0441\u0435 \u043f\u043e\u0434\u043a\u043b\u0430\u0441\u0441\u044b \u0434\u0435\u043b\u0430\u0435\u043c <code>open<\/code><\/p>\n<\/li>\n<li>\n<p>\u0412\u00a0Kotlin \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0434\u0443\u043c\u0430\u0442\u044c \u043f\u0440\u043e <a href=\"https:\/\/kotlinlang.org\/docs\/null-safety.html\" rel=\"noopener noreferrer nofollow\">Nullable and non\u2011nullable types<\/a>. \u0427\u0442\u043e\u0431\u044b \u043d\u0435\u00a0\u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443, \u043f\u043e\u0441\u043b\u0435 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0443\u0431\u0440\u0430\u0442\u044c \u0432\u0441\u0435 <em>Nullable?<\/em> \u0442\u0438\u043f\u044b \u0438 \u0437\u0430\u0442\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c <code>\"?\"<\/code> \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0430\u043c, \u0433\u0434\u0435 \u043e\u043d \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f. \u0410\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f <code>@NonNull<\/code> \u0438 <a href=\"https:\/\/kotlinlang.org\/docs\/null-safety.html#the-operator\" rel=\"noopener noreferrer nofollow\">!! operator<\/a> \u043f\u0440\u0438\u043d\u0443\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0443\u043b\u0435\u0432\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0432\u00a0\u043d\u0435\u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0434\u043b\u044f\u00a0non\u2011nullable \u0442\u0438\u043f\u043e\u0432 \u043d\u0435\u00a0\u043d\u0443\u0436\u0435\u043d\u044b.<\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u044b\u0447\u043d\u043e, \u0434\u043b\u044f\u00a0\u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u0438 \u0438 \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0448\u0438\u0431\u043e\u043a, \u0435\u0441\u043b\u0438 \u0432\u00a0\u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430\u0435 Kotlin \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u0438\u0445 \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0433\u0430\u0442\u044c \u0432\u00a0\u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435: \u0441\u0442\u0430\u0432\u0438\u043c \u043a\u0443\u0440\u0441\u043e\u0440 \u043d\u0430\u00a0\u043b\u044e\u0431\u043e\u0439 \u0438\u0437\u00a0\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0438 \u0434\u0435\u043b\u0430\u0435\u043c <em>Alt+Enter\u2192Put parameters on separate lines<\/em>. <\/p>\n<\/li>\n<li>\n<p>\u0414\u0435\u043b\u0430\u0435\u043c \u0432\u0435\u0437\u0434\u0435, \u0433\u0434\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, <a href=\"https:\/\/kotlinlang.org\/docs\/functions.html#single-expression-functions\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0432\u00a0\u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0443<\/a>, \u0442\u0438\u043f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0435\u0441\u043b\u0438 \u043e\u043d \u043e\u0447\u0435\u0432\u0438\u0434\u0435\u043d \u0438\u043b\u0438\u00a0\u043d\u0435\u0432\u0430\u0436\u0435\u043d, \u043e\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <a href=\"https:\/\/kotlinlang.org\/docs\/strings.html#string-templates\" rel=\"noopener noreferrer nofollow\">String templates<\/a>\u00a0\u2014 \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u0443\u044e \u0444\u0438\u0447\u0443 \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u0440\u044f\u043c\u043e \u0432\u00a0\u0441\u0442\u0440\u043e\u043a\u0443 (\u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 <code>toString<\/code>)<\/p>\n<\/li>\n<li>\n<p>\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b Kotlin <a href=\"https:\/\/kotlinlang.org\/docs\/interfaces.html#properties-in-interfaces\" rel=\"noopener noreferrer nofollow\">\u043c\u043e\u0433\u0443\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430<\/a>. \u041c\u043e\u0439 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <code>HasId<\/code> , \u043e\u0442\u00a0\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e \u0432\u0441\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 JPA \u0438 \u0432\u0441\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b DTO, \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"kotlin\">interface HasId {     @get:Schema(accessMode = Schema.AccessMode.READ_ONLY)     var id: Int?      @JsonIgnore     fun isNew() = id == null      \/\/ doesn't work for hibernate lazy proxy     fun id(): Int {         Assert.notNull(id, \"Entity must has id\")         return id!!     } } <\/code><\/pre>\n<ul>\n<li>\n<p>\u0432 <code>@Schema<\/code>\u0434\u043b\u044f <em>springdoc<\/em> \u043f\u043e\u00a0\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e <a href=\"https:\/\/stackoverflow.com\/questions\/27900041\/rest-put-ids-in-body-or-not\/28025008#28025008\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u044f\u0447\u0435\u043c id \u043f\u043e\u043b\u044f \u0432\u0432\u043e\u0434\u0438\u043c\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432<\/a> \u0432\u00a0Swagger. IDEA \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043a\u00a0\u043d\u0435\u0439 <a href=\"https:\/\/kotlinlang.org\/docs\/annotations.html#annotation-use-site-targets\" rel=\"noopener noreferrer nofollow\">\u00abget\/set use\u2011site target\u00bb<\/a>.<\/p>\n<\/li>\n<li>\n<p>\u0412 <code>id()<\/code> \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430\u00a0null \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f <a href=\"https:\/\/kotlinlang.org\/docs\/null-safety.html#the-operator\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u0438\u043d\u0443\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043a\u00a0non\u2011nullable type<\/a>.<\/p>\n<\/li>\n<\/ul>\n<h2>DTO<\/h2>\n<ul>\n<li>\n<p>\u041a\u043b\u0430\u0441\u0441\u044b TO \u0431\u0443\u0434\u0435\u043c \u0434\u0435\u043b\u0430\u0442\u044c <a href=\"https:\/\/kotlinlang.org\/docs\/data-classes.html\" rel=\"noopener noreferrer nofollow\">\u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445<\/a> (\u043f\u043e \u0441\u0443\u0442\u0438 \u044d\u0442\u043e \u0442\u0430\u043a \u0438 \u0435\u0441\u0442\u044c, \u043a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e \u0443\u0434\u043e\u0431\u043d\u043e \u0441\u0440\u0430\u0437\u0443 \u0438\u043c\u0435\u0442\u044c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 <code>equals()\/hashCode()\/copy()<\/code>). \u0414\u043b\u044f\u00a0\u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0442\u044c \u0432\u0441\u0435 \u043f\u043e\u043b\u044f \u0432\u00a0\u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 (\u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u043f\u043e\u0445\u043e\u0436\u0435 \u043d\u0430\u00a0Java records, \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u044f \u0431\u0443\u0434\u0443\u0442 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0435 <code>var<\/code>). \u041f\u0440\u0438\u00a0\u044d\u0442\u043e\u043c \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u0438 \u0438\u0445 \u043f\u043e\u043b\u044f <a href=\"https:\/\/stackoverflow.com\/a\/55701197\/548473\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0442\u044c <\/a><code>open<\/code>, \u0430\u00a0\u0432\u00a0\u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u043c\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u0430\u0445 \u043f\u043e\u043b\u044f \u043f\u0435\u0440\u0435\u043a\u0440\u044b\u0432\u0430\u0442\u044c <code>override<\/code>. \u0422\u0430\u043a\u0436\u0435, \u0434\u043b\u044f <a href=\"https:\/\/kotlinlang.org\/docs\/classes.html#a2a48691\" rel=\"noopener noreferrer nofollow\">\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0431\u0435\u0437\u00a0\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432<\/a>, \u0437\u0430\u0434\u0430\u0435\u043c \u0432\u0441\u0435\u043c \u043f\u043e\u043b\u044f\u043c \u0432\u00a0\u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u00a0\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e. Lombok \u0432\u00a0Kotlin \u043d\u0435\u0442, \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c Java \u043a\u043e\u0434 \u0431\u0435\u0437\u00a0\u0435\u0433\u043e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439 \u0438 \u043f\u043e <em>Alt+Enter<\/em> \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c <code>import<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0435 <a href=\"https:\/\/kotlinlang.org\/docs\/null-safety.html\" rel=\"noopener noreferrer nofollow\">Non\u2011Null \u0442\u0438\u043f\u044b<\/a> \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c <code>=\"\"<\/code>  <\/p>\n<\/li>\n<li>\n<p>\u0427\u0442\u043e\u0431\u044b \u043d\u0435\u00a0\u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c\u00a0\u043b\u0438\u0448\u043d\u0438\u0445 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 (\u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u00a0\u043f\u043e\u043b\u044f, \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044f \u0433\u0435\u0442\u0442\u0435\u0440\u044b \u0438 \u0441\u0435\u0442\u0442\u0435\u0440\u044b) <a href=\"https:\/\/kotlinlang.org\/docs\/annotations.html#annotation-use-site-targets\" rel=\"noopener noreferrer nofollow\">\u0434\u0435\u043b\u0430\u0435\u043c \u043a\u00a0\u043d\u0438\u043c use\u2011site targets \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438<\/a> <code>field:<\/code>. <\/p>\n<\/li>\n<\/ul>\n<h3>Entities<\/h3>\n<p>Entities \u043a\u043b\u0430\u0441\u0441\u044b <strong>\u043d\u0435<\/strong> \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 <a href=\"https:\/\/github.com\/spring-guides\/tut-spring-boot-kotlin#persistence-with-jpa\" rel=\"noopener noreferrer nofollow\">\u0441\u043c\u043e\u0442\u0440\u0438 Note<\/a> (\u043d\u0430\u043f\u043e\u043c\u043d\u044e, \u0447\u0442\u043e\u00a0\u043a\u043b\u0430\u0441\u0441\u044b \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0443\u00a0\u043d\u0430\u0441 \u0447\u0435\u0440\u0435\u0437 <a href=\"https:\/\/github.com\/spring-guides\/tut-spring-boot-kotlin#plugins\" rel=\"noopener noreferrer nofollow\">plugin.jpa<\/a>). \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e \u0432\u00a0\u043d\u0438\u0445, \u0434\u043b\u044f\u00a0\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b Hibernate, \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c <code>equals()\/hashcode()<\/code>, \u043a\u0430\u043a\u00a0\u044d\u0442\u043e \u0434\u0435\u043b\u0430\u044e\u0442 \u043a\u043b\u0430\u0441\u0441\u044b \u0434\u0430\u043d\u043d\u044b\u0445. \u041a\u00a0\u043f\u043e\u043b\u044f\u043c \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0443\u0436\u0435\u043d \u0434\u043e\u0441\u0442\u0443\u043f \u0438\u0437\u0432\u043d\u0435, \u0434\u0435\u043b\u0430\u0435\u043c \u0438\u0445 <a href=\"https:\/\/stackoverflow.com\/a\/38328352\/548473\" rel=\"noopener noreferrer nofollow\">public \u043f\u043e\u00a0\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e<\/a> (\u0441\u043c.<a href=\"https:\/\/kotlinlang.org\/docs\/properties.html\" rel=\"noopener noreferrer nofollow\">\u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430<\/a>). <\/p>\n<ul>\n<li>\n<p>\u041f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u043c \u0432\u0441\u0435 \u043f\u043e\u043b\u044f \u0432\u00a0\u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u00a0\u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f\u043c <code>@field:<\/code>, \u0434\u043b\u044f\u00a0\u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u0431\u0435\u0437\u00a0\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0434\u0435\u043b\u0430\u0435\u043c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043f\u043e\u00a0\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u043a\u043e\u0434 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043f\u0440\u0438\u0447\u0435\u0441\u044b\u0432\u0430\u0435\u043c \u0432 <a href=\"https:\/\/kotlinlang.org\/docs\/coding-conventions.html#control-flow-statements\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0438\u043b\u0435 Kotlin<\/a> (put short branches on the same line as the condition, without braces)<\/p>\n<\/li>\n<li>\n<p>\u041c\u043e\u0439 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <code>BaseEntity<\/code> \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"kotlin\">@MappedSuperclass @Access(AccessType.FIELD) abstract class BaseEntity(     @field:Id     @field:GeneratedValue(strategy = GenerationType.IDENTITY)     override var id: Int? = null  ) : HasId {     \/\/    https:\/\/stackoverflow.com\/questions\/1638723     override fun equals(other: Any?): Boolean {         if (this === other) return true         if (other == null || javaClass != ProxyUtils.getUserClass(other)) return false         val that = other as BaseEntity         return id != null &amp;&amp; id == that.id     }      override fun hashCode() = id ?: 0     override fun toString() = \"${javaClass.simpleName}:$id\" }<\/code><\/pre>\n<ul>\n<li>\n<p>\u0414\u043b\u044f\u00a0<code>BaseEntity.hashCode<\/code>\u00a0\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u00a0<a href=\"https:\/\/kotlinlang.org\/docs\/null-safety.html#elvis-operator\" rel=\"noopener noreferrer nofollow\">Elvis operator<\/a>.<\/p>\n<\/li>\n<\/ul>\n<h2>Repositories<\/h2>\n<ul>\n<li>\n<p>\u0414\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0432\u00a0<code>BaseRepository<\/code>\u00a0Kotlin \u043d\u0435 \u0432\u0438\u0434\u0438\u0442, \u043d\u0443\u0436\u043d\u043e\u00a0<a href=\"https:\/\/stackoverflow.com\/a\/77298354\/548473\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0438\u0445 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443<\/a>: \u043e\u043f\u0446\u0438\u044f\u00a0<code>-Xjvm-default=all<\/code>\u00a0\u0438\u00a0<code>@JvmDefaultWithCompatibility<\/code><\/p>\n<\/li>\n<\/ul>\n<p>\u041c\u043e\u0439 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e <a href=\"https:\/\/stackoverflow.com\/questions\/42781264\/multiple-base-repositories-in-spring-data-jpa\" rel=\"noopener noreferrer nofollow\">\u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0442\u0441\u044f \u0432\u0441\u0435 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438<\/a>:<\/p>\n<pre><code class=\"kotlin\">@NoRepositoryBean @JvmDefaultWithCompatibility interface BaseRepository&lt;T> : JpaRepository&lt;T, Int?> {     \/\/    https:\/\/docs.spring.io\/spring-data\/jpa\/docs\/current\/reference\/html\/#jpa.query.spel-expressions     @Transactional     @Modifying     @Query(\"DELETE FROM #{#entityName} e WHERE e.id=:id\")     fun delete(id: Int): Int      \/\/  https:\/\/stackoverflow.com\/a\/60695301\/548473 (existed delete code 204, not existed: 404)     fun deleteExisted(id: Int) {         if (delete(id) == 0) throw NotFoundException(\"Entity with id=$id not found\")     }      fun getExisted(id: Int): T = findById(id).orElseThrow { NotFoundException(\"Entity with id=$id not found\") } }<\/code><\/pre>\n<ul>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u043c\u044b \u043d\u0435 \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u044b \u043a <code>JpaRepository API<\/code>\u00a0, \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c Java Optional \u043d\u0430 Kotlin nullable,\u00a0<a href=\"https:\/\/typealias.com\/guides\/java-optionals-and-kotlin-nulls\/#orelsethrow\" rel=\"noopener noreferrer nofollow\">\u043f\u0435\u0440\u0435\u0443\u0447\u0438\u0432\u0430\u0435\u043c\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 nullable \u0435\u0449\u0435 \u0440\u0430\u0437<\/a> \ud83d\ude42<\/p>\n<\/li>\n<\/ul>\n<h2>\u0417\u0430\u043b\u043e\u0433\u0438\u043d\u0435\u043d\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c<\/h2>\n<ul>\n<li>\n<p>\u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\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 \u0438\u0437 \u043b\u044e\u0431\u043e\u0433\u043e \u043c\u0435\u0441\u0442\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432\u043c\u0435\u0441\u0442\u043e\u00a0<a href=\"https:\/\/kotlinlang.org\/docs\/object-declarations.html#companion-objects\" rel=\"noopener noreferrer nofollow\">companion objects<\/a>\u00a0\u0441\u0434\u0435\u043b\u0430\u043b\u00a0<a href=\"https:\/\/kotlinlang.org\/docs\/functions.html#function-scope\" rel=\"noopener noreferrer nofollow\">top-level functions<\/a>  <\/p>\n<\/li>\n<li>\n<p>\u0414\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0432\u00a0<code>authUser<\/code>\u00a0\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u00a0<a href=\"https:\/\/www.baeldung.com\/kotlin\/preconditions\" rel=\"noopener noreferrer nofollow\">Preconditions<\/a><\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u043b\u043b\u0438\u0437\u0438\u044e \u0438\u043c\u0435\u043d\u0438 \u0441\u00a0<em>org.springframework.security.core.userdetails.User<\/em>, \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e\u00a0<a href=\"https:\/\/kotlinlang.org\/docs\/packages.html#imports\" rel=\"noopener noreferrer nofollow\">import as SecurityUser<\/a><\/p>\n<\/li>\n<li>\n<p><code>AuthUser.user<\/code>\u00a0\u043f\u0440\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u0435\u0440\u0435\u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u0434\u0435\u043b\u0430\u0435\u043c \u0435\u0433\u043e\u00a0<code>var<\/code>  <\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"kotlin\">import org.springframework.security.core.userdetails.User as SecurityUser  fun safeAuthUser(): AuthUser? {     val auth = SecurityContextHolder.getContext().authentication ?: return null     val principal = auth.principal     return if (principal is AuthUser) principal else null }  fun authUser(): AuthUser = checkNotNull(safeAuthUser()) { \"No authorized user found\" }  class AuthUser(var user: User) : SecurityUser(user.email, user.password, user.roles) {     fun id() = user.id()     fun hasRole(role: Role) = user.hasRole(role)      override fun toString() = \"AuthUser:${user.id}[${user.email}]\" }<\/code><\/pre>\n<h2>\u041b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h2>\n<p>\u041d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043a\u0440\u0430\u0441\u0438\u0432\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441\u00a0\u043b\u043e\u0433\u0430\u043c\u0438 \u0447\u0435\u0440\u0435\u0437 <a href=\"https:\/\/github.com\/MicroUtils\/kotlin-logging\" rel=\"noopener noreferrer nofollow\">kotlin\u2011logging<\/a>: \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c <em>kotlin\u2011logging\u2011jvm<\/em><\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/realjenius.com\/2017\/08\/31\/logging-in-kotlin\/\" rel=\"noopener noreferrer nofollow\">Kotlin Logging Without the Fuss<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/stackoverflow.com\/questions\/57728079\/kotlin-best-way-to-log-using-slf4j\" rel=\"noopener noreferrer nofollow\">Kotlin best way to log<\/a><\/p>\n<\/li>\n<\/ul>\n<h3>\u0411\u0438\u043d\u044b Spring<\/h3>\n<ul>\n<li>\n<p> \u0414\u043b\u044f <code>@Autowired<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <a href=\"https:\/\/kotlinlang.org\/docs\/properties.html#late-initialized-properties-and-variables\" rel=\"noopener noreferrer nofollow\">\u043e\u0442\u043b\u043e\u0436\u0435\u043d\u043d\u0443\u044e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e<\/a> (<code>lateinit var<\/code> )<\/p>\n<\/li>\n<li>\n<p>\u0412\u0441\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u0438 <strong>\u043f\u0440\u043e\u043a\u0441\u0438\u0440\u0443\u0435\u0442\u0441\u044f Spring<\/strong> \u0434\u043e\u043b\u0436\u043d\u044b\u00a0\u0431\u044b\u0442\u044c <code>open<\/code> <\/p>\n<\/li>\n<\/ul>\n<h3>\u041e\u0431\u0449\u0438\u0435 \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u044f<\/h3>\n<ul>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c, \u0433\u0434\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u043e\u0435 <a href=\"https:\/\/kotlinlang.org\/docs\/control-flow.html#when-expression\" rel=\"noopener noreferrer nofollow\">\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 when<\/a>, \u0437\u0430\u043c\u0435\u043d\u0443 Java <code>Optional<\/code> \u043d\u0430 <a href=\"https:\/\/typealias.com\/guides\/java-optionals-and-kotlin-nulls\/\" rel=\"noopener noreferrer nofollow\">Kotlin Nulls<\/a> \u0438 <a href=\"https:\/\/kotlinlang.org\/docs\/properties.html#compile-time-constants\" rel=\"noopener noreferrer nofollow\">\u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438<\/a><\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <a href=\"https:\/\/kotlinlang.org\/docs\/scope-functions.html\" rel=\"noopener noreferrer nofollow\">Scope functions<\/a>, \u0432\u044b\u0431\u043e\u0440 \u043d\u0443\u0436\u043d\u043e\u0439 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u043e\u00a0\u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0435 <a href=\"https:\/\/kotlinlang.org\/docs\/scope-functions.html#function-selection\" rel=\"noopener noreferrer nofollow\">Function selection<\/a><\/p>\n<\/li>\n<li>\n<p>\u0412\u00a0Kotlin <a href=\"https:\/\/kotlinlang.org\/docs\/java-to-kotlin-interop.html#checked-exceptions\" rel=\"noopener noreferrer nofollow\">\u043d\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c\u044b\u0445 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439<\/a>, <code>@Throws<\/code> \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f\u00a0\u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438\u0437\u00a0Java <\/p>\n<\/li>\n<li>\n<p>Kotlin \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 <a href=\"https:\/\/kotlinlang.org\/docs\/extensions.html\" rel=\"noopener noreferrer nofollow\">\u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u043f\u0443\u0442\u0451\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430<\/a>, \u0447\u0442\u043e\u00a0\u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u043a\u043e\u0434 \u0435\u0449\u0435 \u0431\u043e\u043b\u0435\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e\u2011\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c (<a href=\"https:\/\/medium.com\/@y9vad9\/extension-oriented-design-6d9898c33e5f\" rel=\"noopener noreferrer nofollow\">Extension Oriented Design<\/a>). \u0421\u0442\u0430\u0440\u0430\u0439\u0442\u0435\u0441\u044c \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u044d\u0442\u043e\u0442 \u0434\u0438\u0437\u0430\u0439\u043d \u0432\u0435\u0437\u0434\u0435, \u0433\u0434\u0435 \u043a\u00a0\u043e\u0431\u044a\u0435\u043a\u0442\u0443 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430. \u0414\u043b\u044f\u00a0\u0432\u0441\u0435\u0445 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439 \u0443\u0440\u043e\u0432\u043d\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0441\u043e\u0437\u0434\u0430\u043b \u0432\u00a0\u043a\u043e\u0440\u043d\u0435\u0432\u043e\u043c \u043f\u0430\u043a\u0435\u0442\u0435 <code>Extensions.kt<\/code>  <\/p>\n<\/li>\n<li>\n<p>Kotlin \u043f\u043e\u00a0\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 getter\/setter \u0434\u043b\u044f\u00a0\u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u0435\u0439 \u043a\u043b\u0430\u0441\u0441\u0430. \u0412\u00a0\u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0433\u043e \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442, \u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 <a href=\"https:\/\/stackoverflow.com\/a\/62338482\/548473\" rel=\"noopener noreferrer nofollow\">\u0437\u0430\u043f\u0440\u0435\u0442 \u043d\u0430\u00a0\u0430\u0432\u0442\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u0447\u0435\u0440\u0435\u0437 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e @JvmField<\/a>  <\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043c\u0435\u043d\u044f\u0435\u043c Java \u043a\u043b\u0430\u0441\u0441\u044b <code>Class<\/code>  \u043d\u0430\u00a0Kotlin <a href=\"https:\/\/kotlinlang.org\/api\/latest\/jvm\/stdlib\/kotlin.reflect\/-k-class\/\" rel=\"noopener noreferrer nofollow\">KClass<\/a> \u0438 Java \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u043d\u0430 <a href=\"https:\/\/kotlinlang.org\/docs\/collections-overview.html\" rel=\"noopener noreferrer nofollow\">\u0438\u0445 Kotlin \u0430\u043d\u0430\u043b\u043e\u0433\u0438<\/a><\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0432\u00a0\u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u00a0\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u043c\u043e\u0436\u043d\u043e \u043c\u0435\u043d\u044f\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <a href=\"https:\/\/kotlinlang.org\/docs\/functions.html#named-arguments\" rel=\"noopener noreferrer nofollow\">\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440<\/a> <\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u0430\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u043a \u0435\u0449\u0435 \u0440\u0430\u0437\u00a0\u2014 \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0435\u00a0\u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0430 \u0434\u043b\u044f\u00a0\u0447\u0442\u0435\u043d\u0438\u044f. \u042d\u0442\u043e \u0441\u043a\u043e\u0440\u0435\u0435 \u043d\u0430\u0431\u043e\u0440 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0440\u0430\u0432\u0438\u043b \u0438\u0437\u00a0\u043a\u0443\u0440\u0441\u0430 Spring Boot REST API \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430\u00a0Kotlin<strong> <\/strong>(\u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043d\u0430\u0448\u0438\u0445 \u043a\u0443\u0440\u0441\u043e\u0432 \u00ab\u0418\u0437 Middle \u0432\u00a0Senior\u00bb, \u0441\u043c. \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u043f\u043e\u0441\u0442 \u043f\u043e\u00a0\u043a\u0443\u0440\u0441\u0443 <strong>&#171;<\/strong><a href=\"https:\/\/habr.com\/ru\/articles\/765332\/\" rel=\"noopener noreferrer nofollow\">\u0420\u0430\u0431\u043e\u0442\u0430 \u0441\u00a0\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u0432\u00a0Java<\/a><strong>&#171;<\/strong>)<strong> <\/strong>\u0434\u043b\u044f\u00a0\u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0441\u0432\u043e\u0435\u0433\u043e Java \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f (\u0432 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 Spring Boot), \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u0431\u0440\u0430\u0449\u0430\u0439\u0442\u0435\u0441\u044c \u043a\u00a0\u043d\u0435\u0439, \u043a\u043e\u0433\u0434\u0430 \u0440\u0435\u0448\u0438\u0442\u0435\u0441\u044c \u043d\u0430\u00a0\u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e.<\/p>\n<p>\u0418 \u0434\u0430\u00a0\u043f\u0440\u0435\u0431\u0443\u0434\u0435\u0442 \u0441\u00a0\u0432\u0430\u043c\u0438 \u0441\u0438\u043b\u0430:)!<\/p>\n<p>PS: \u0431\u0443\u0434\u0443 \u043f\u0440\u0438\u0437\u043d\u0430\u0442\u0435\u043b\u0435\u043d \u0437\u0430\u00a0\u043b\u044e\u0431\u044b\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u044f \u0438 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u043a\u00a0\u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u043a\u043e\u0434\u0430 \u043d\u0430\u00a0Kotlin.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><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\/articles\/777824\/\"> https:\/\/habr.com\/ru\/articles\/777824\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"bordered full-width\"><\/figure>\n<p>\u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e \u0434\u043b\u044f\u00a0\u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0441\u0432\u043e\u0435\u0433\u043e Java \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f (\u0432 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 Spring Boot) \u043d\u0430\u00a0Kotlin. \u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430\u00a0\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e: <a href=\"https:\/\/kotlinlang.ru\/docs\" rel=\"noopener noreferrer nofollow\">Kotlin Docs<\/a> (\u043d\u0430 \u0440\u0443\u0441\u0441\u043a\u043e\u043c \u0441\u0441\u044b\u043b\u043a\u0438 \u043c\u043e\u0436\u043d\u043e <a href=\"https:\/\/kotlinlang.ru\/docs\/\" rel=\"noopener noreferrer nofollow\">\u0437\u0430\u043c\u0435\u043d\u044f\u0442\u044c \u043d\u0430\u00a0&#171;ru&#187;<\/a>,  \u0443 \u043c\u0435\u043d\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0437 VPN).<\/p>\n<h2>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f Gradle\u2011Kotlin \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/h2>\n<ul>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 Gradle\u2011Kotlin \u043f\u0440\u043e\u0435\u043a\u0442: <a href=\"https:\/\/kotlinlang.org\/docs\/jvm-create-project-with-spring-boot.html\" rel=\"noopener noreferrer nofollow\">Create a Spring Boot project with Kotlin<\/a>. <strong>Kts<\/strong> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u043c \u0434\u043b\u044f <a href=\"https:\/\/sebhastian.com\/kotlin-file-extension\/\" rel=\"noopener noreferrer nofollow\">Kotlin \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432<\/a>. \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e: <a href=\"https:\/\/github.com\/spring-guides\/tut-spring-boot-kotlin#understanding-the-gradle-build\" rel=\"noopener noreferrer nofollow\">Understanding the Gradle Build<\/a>.<\/p>\n<\/li>\n<li>\n<p>\u041c\u0435\u043d\u044f\u0435\u043c <a href=\"https:\/\/kotlinlang.org\/docs\/releases.html#release-details\" rel=\"noopener noreferrer nofollow\">\u0432\u0435\u0440\u0441\u0438\u044e Kotlin \u043d\u0430\u00a0\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e<\/a> \u0438 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0430\u0435\u043c\/\u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442<\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0431\u0435\u0437\u00a0\u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u044b <em>src\/main\/resources<\/em> \u0438 <em>src\/test\/resources<\/em> <\/p>\n<\/li>\n<\/ul>\n<h3>\u041c\u0438\u0433\u0440\u0430\u0446\u0438\u044f \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432\/\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432<\/h3>\n<blockquote>\n<p>\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u044b Java \u0432\u00a0Kotlin \u0432\u00a0IDEA \u043c\u043e\u0436\u043d\u043e <a href=\"https:\/\/www.tutorialkart.com\/kotlin\/convert-java-file-to-kotlin-file\" rel=\"noopener noreferrer nofollow\">\u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044e (Ctrl+Alt+Shift+K) \u0438\u043b\u0438\u00a0\u043f\u0440\u043e\u0441\u0442\u043e \u043a\u043e\u043f\u0438\u0440\u0443\u044f Java \u043a\u043e\u0434 \u0432\u00a0Kotlin \u043a\u043b\u0430\u0441\u0441<\/a>. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043e\u0431\u044b\u0447\u043d\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0440\u0443\u0447\u043d\u044b\u0435 \u043f\u0440\u0430\u0432\u043a\u0438.<\/p>\n<\/blockquote>\n<ul>\n<li>\n<p>\u0412\u00a0Kotlin \u0432\u00a0\u043e\u0434\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043f\u043e\u044d\u0442\u043e\u043c\u0443, \u0435\u0441\u043b\u0438 \u043a\u043b\u0430\u0441\u0441\u044b \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0435, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439 \u0438 \u0438\u0445 \u0432\u00a0\u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e, \u0438\u0445 \u043f\u043e\u043c\u0435\u0449\u044f\u044e\u0442 \u0432\u00a0\u043e\u0434\u0438\u043d \u043e\u0431\u0449\u0438\u0439 \u0441 <a href=\"https:\/\/kotlinlang.org\/docs\/coding-conventions.html#source-file-names\" rel=\"noopener noreferrer nofollow\">\u043e\u0431\u043e\u043f\u0449\u0430\u044e\u0449\u0438\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/kotlinlang.org\/docs\/inheritance.html\" rel=\"noopener noreferrer nofollow\">\u041d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0435 \u0438 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b<\/a>, \u0430\u00a0\u043f\u043e\u00a0\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e Kotlin \u043a\u043b\u0430\u0441\u0441\u044b <code>final<\/code>. \u0412\u0441\u0435 \u043f\u043e\u0434\u043a\u043b\u0430\u0441\u0441\u044b \u0434\u0435\u043b\u0430\u0435\u043c <code>open<\/code><\/p>\n<\/li>\n<li>\n<p>\u0412\u00a0Kotlin \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0434\u0443\u043c\u0430\u0442\u044c \u043f\u0440\u043e <a href=\"https:\/\/kotlinlang.org\/docs\/null-safety.html\" rel=\"noopener noreferrer nofollow\">Nullable and non\u2011nullable types<\/a>. \u0427\u0442\u043e\u0431\u044b \u043d\u0435\u00a0\u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443, \u043f\u043e\u0441\u043b\u0435 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0443\u0431\u0440\u0430\u0442\u044c \u0432\u0441\u0435 <em>Nullable?<\/em> \u0442\u0438\u043f\u044b \u0438 \u0437\u0430\u0442\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c <code>\"?\"<\/code> \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0430\u043c, \u0433\u0434\u0435 \u043e\u043d \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f. \u0410\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f <code>@NonNull<\/code> \u0438 <a href=\"https:\/\/kotlinlang.org\/docs\/null-safety.html#the-operator\" rel=\"noopener noreferrer nofollow\">!! operator<\/a> \u043f\u0440\u0438\u043d\u0443\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0443\u043b\u0435\u0432\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0432\u00a0\u043d\u0435\u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0434\u043b\u044f\u00a0non\u2011nullable \u0442\u0438\u043f\u043e\u0432 \u043d\u0435\u00a0\u043d\u0443\u0436\u0435\u043d\u044b.<\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u044b\u0447\u043d\u043e, \u0434\u043b\u044f\u00a0\u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u0438 \u0438 \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0448\u0438\u0431\u043e\u043a, \u0435\u0441\u043b\u0438 \u0432\u00a0\u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430\u0435 Kotlin \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u0438\u0445 \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0433\u0430\u0442\u044c \u0432\u00a0\u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435: \u0441\u0442\u0430\u0432\u0438\u043c \u043a\u0443\u0440\u0441\u043e\u0440 \u043d\u0430\u00a0\u043b\u044e\u0431\u043e\u0439 \u0438\u0437\u00a0\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0438 \u0434\u0435\u043b\u0430\u0435\u043c <em>Alt+Enter\u2192Put parameters on separate lines<\/em>. <\/p>\n<\/li>\n<li>\n<p>\u0414\u0435\u043b\u0430\u0435\u043c \u0432\u0435\u0437\u0434\u0435, \u0433\u0434\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, <a href=\"https:\/\/kotlinlang.org\/docs\/functions.html#single-expression-functions\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0432\u00a0\u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0443<\/a>, \u0442\u0438\u043f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0435\u0441\u043b\u0438 \u043e\u043d \u043e\u0447\u0435\u0432\u0438\u0434\u0435\u043d \u0438\u043b\u0438\u00a0\u043d\u0435\u0432\u0430\u0436\u0435\u043d, \u043e\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <a href=\"https:\/\/kotlinlang.org\/docs\/strings.html#string-templates\" rel=\"noopener noreferrer nofollow\">String templates<\/a>\u00a0\u2014 \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u0443\u044e \u0444\u0438\u0447\u0443 \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u0440\u044f\u043c\u043e \u0432\u00a0\u0441\u0442\u0440\u043e\u043a\u0443 (\u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 <code>toString<\/code>)<\/p>\n<\/li>\n<li>\n<p>\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b Kotlin <a href=\"https:\/\/kotlinlang.org\/docs\/interfaces.html#properties-in-interfaces\" rel=\"noopener noreferrer nofollow\">\u043c\u043e\u0433\u0443\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430<\/a>. \u041c\u043e\u0439 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <code>HasId<\/code> , \u043e\u0442\u00a0\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e \u0432\u0441\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 JPA \u0438 \u0432\u0441\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b DTO, \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"kotlin\">interface HasId {     @get:Schema(accessMode = Schema.AccessMode.READ_ONLY)     var id: Int?      @JsonIgnore     fun isNew() = id == null      \/\/ doesn't work for hibernate lazy proxy     fun id(): Int {         Assert.notNull(id, \"Entity must has id\")         return id!!     } } <\/code><\/pre>\n<ul>\n<li>\n<p>\u0432 <code>@Schema<\/code>\u0434\u043b\u044f <em>springdoc<\/em> \u043f\u043e\u00a0\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e <a href=\"https:\/\/stackoverflow.com\/questions\/27900041\/rest-put-ids-in-body-or-not\/28025008#28025008\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u044f\u0447\u0435\u043c id \u043f\u043e\u043b\u044f \u0432\u0432\u043e\u0434\u0438\u043c\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432<\/a> \u0432\u00a0Swagger. IDEA \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043a\u00a0\u043d\u0435\u0439 <a href=\"https:\/\/kotlinlang.org\/docs\/annotations.html#annotation-use-site-targets\" rel=\"noopener noreferrer nofollow\">\u00abget\/set use\u2011site target\u00bb<\/a>.<\/p>\n<\/li>\n<li>\n<p>\u0412 <code>id()<\/code> \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430\u00a0null \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f <a href=\"https:\/\/kotlinlang.org\/docs\/null-safety.html#the-operator\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u0438\u043d\u0443\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043a\u00a0non\u2011nullable type<\/a>.<\/p>\n<\/li>\n<\/ul>\n<h2>DTO<\/h2>\n<ul>\n<li>\n<p>\u041a\u043b\u0430\u0441\u0441\u044b TO \u0431\u0443\u0434\u0435\u043c \u0434\u0435\u043b\u0430\u0442\u044c <a href=\"https:\/\/kotlinlang.org\/docs\/data-classes.html\" rel=\"noopener noreferrer nofollow\">\u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445<\/a> (\u043f\u043e \u0441\u0443\u0442\u0438 \u044d\u0442\u043e \u0442\u0430\u043a \u0438 \u0435\u0441\u0442\u044c, \u043a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e \u0443\u0434\u043e\u0431\u043d\u043e \u0441\u0440\u0430\u0437\u0443 \u0438\u043c\u0435\u0442\u044c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 <code>equals()\/hashCode()\/copy()<\/code>). \u0414\u043b\u044f\u00a0\u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0442\u044c \u0432\u0441\u0435 \u043f\u043e\u043b\u044f \u0432\u00a0\u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 (\u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u043f\u043e\u0445\u043e\u0436\u0435 \u043d\u0430\u00a0Java records, \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u044f \u0431\u0443\u0434\u0443\u0442 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0435 <code>var<\/code>). \u041f\u0440\u0438\u00a0\u044d\u0442\u043e\u043c \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u0438 \u0438\u0445 \u043f\u043e\u043b\u044f <a href=\"https:\/\/stackoverflow.com\/a\/55701197\/548473\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0442\u044c <\/a><code>open<\/code>, \u0430\u00a0\u0432\u00a0\u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u043c\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u0430\u0445 \u043f\u043e\u043b\u044f \u043f\u0435\u0440\u0435\u043a\u0440\u044b\u0432\u0430\u0442\u044c <code>override<\/code>. \u0422\u0430\u043a\u0436\u0435, \u0434\u043b\u044f <a href=\"https:\/\/kotlinlang.org\/docs\/classes.html#a2a48691\" rel=\"noopener noreferrer nofollow\">\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0431\u0435\u0437\u00a0\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432<\/a>, \u0437\u0430\u0434\u0430\u0435\u043c \u0432\u0441\u0435\u043c \u043f\u043e\u043b\u044f\u043c \u0432\u00a0\u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u00a0\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e. Lombok \u0432\u00a0Kotlin \u043d\u0435\u0442, \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c Java \u043a\u043e\u0434 \u0431\u0435\u0437\u00a0\u0435\u0433\u043e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439 \u0438 \u043f\u043e <em>Alt+Enter<\/em> \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c <code>import<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0435 <a href=\"https:\/\/kotlinlang.org\/docs\/null-safety.html\" rel=\"noopener noreferrer nofollow\">Non\u2011Null \u0442\u0438\u043f\u044b<\/a> \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c <code>=\"\"<\/code>  <\/p>\n<\/li>\n<li>\n<p>\u0427\u0442\u043e\u0431\u044b \u043d\u0435\u00a0\u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c\u00a0\u043b\u0438\u0448\u043d\u0438\u0445 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 (\u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u00a0\u043f\u043e\u043b\u044f, \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044f \u0433\u0435\u0442\u0442\u0435\u0440\u044b \u0438 \u0441\u0435\u0442\u0442\u0435\u0440\u044b) <a href=\"https:\/\/kotlinlang.org\/docs\/annotations.html#annotation-use-site-targets\" rel=\"noopener noreferrer nofollow\">\u0434\u0435\u043b\u0430\u0435\u043c \u043a\u00a0\u043d\u0438\u043c use\u2011site targets \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438<\/a> <code>field:<\/code>. <\/p>\n<\/li>\n<\/ul>\n<h3>Entities<\/h3>\n<p>Entities \u043a\u043b\u0430\u0441\u0441\u044b <strong>\u043d\u0435<\/strong> \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 <a href=\"https:\/\/github.com\/spring-guides\/tut-spring-boot-kotlin#persistence-with-jpa\" rel=\"noopener noreferrer nofollow\">\u0441\u043c\u043e\u0442\u0440\u0438 Note<\/a> (\u043d\u0430\u043f\u043e\u043c\u043d\u044e, \u0447\u0442\u043e\u00a0\u043a\u043b\u0430\u0441\u0441\u044b \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0443\u00a0\u043d\u0430\u0441 \u0447\u0435\u0440\u0435\u0437 <a href=\"https:\/\/github.com\/spring-guides\/tut-spring-boot-kotlin#plugins\" rel=\"noopener noreferrer nofollow\">plugin.jpa<\/a>). \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e \u0432\u00a0\u043d\u0438\u0445, \u0434\u043b\u044f\u00a0\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b Hibernate, \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c <code>equals()\/hashcode()<\/code>, \u043a\u0430\u043a\u00a0\u044d\u0442\u043e \u0434\u0435\u043b\u0430\u044e\u0442 \u043a\u043b\u0430\u0441\u0441\u044b \u0434\u0430\u043d\u043d\u044b\u0445. \u041a\u00a0\u043f\u043e\u043b\u044f\u043c \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0443\u0436\u0435\u043d \u0434\u043e\u0441\u0442\u0443\u043f \u0438\u0437\u0432\u043d\u0435, \u0434\u0435\u043b\u0430\u0435\u043c \u0438\u0445 <a href=\"https:\/\/stackoverflow.com\/a\/38328352\/548473\" rel=\"noopener noreferrer nofollow\">public \u043f\u043e\u00a0\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e<\/a> (\u0441\u043c.<a href=\"https:\/\/kotlinlang.org\/docs\/properties.html\" rel=\"noopener noreferrer nofollow\">\u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430<\/a>). <\/p>\n<ul>\n<li>\n<p>\u041f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u043c \u0432\u0441\u0435 \u043f\u043e\u043b\u044f \u0432\u00a0\u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u00a0\u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f\u043c <code>@field:<\/code>, \u0434\u043b\u044f\u00a0\u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u0431\u0435\u0437\u00a0\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0434\u0435\u043b\u0430\u0435\u043c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043f\u043e\u00a0\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u043a\u043e\u0434 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043f\u0440\u0438\u0447\u0435\u0441\u044b\u0432\u0430\u0435\u043c \u0432 <a href=\"https:\/\/kotlinlang.org\/docs\/coding-conventions.html#control-flow-statements\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0438\u043b\u0435 Kotlin<\/a> (put short branches on the same line as the condition, without braces)<\/p>\n<\/li>\n<li>\n<p>\u041c\u043e\u0439 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <code>BaseEntity<\/code> \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"kotlin\">@MappedSuperclass @Access(AccessType.FIELD) abstract class BaseEntity(     @field:Id     @field:GeneratedValue(strategy = GenerationType.IDENTITY)     override var id: Int? = null  ) : HasId {     \/\/    https:\/\/stackoverflow.com\/questions\/1638723     override fun equals(other: Any?): Boolean {         if (this === other) return true         if (other == null || javaClass != ProxyUtils.getUserClass(other)) return false         val that = other as BaseEntity         return id != null &amp;&amp; id == that.id     }      override fun hashCode() = id ?: 0     override fun toString() = \"${javaClass.simpleName}:$id\" }<\/code><\/pre>\n<ul>\n<li>\n<p>\u0414\u043b\u044f\u00a0<code>BaseEntity.hashCode<\/code>\u00a0\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u00a0<a href=\"https:\/\/kotlinlang.org\/docs\/null-safety.html#elvis-operator\" rel=\"noopener noreferrer nofollow\">Elvis operator<\/a>.<\/p>\n<\/li>\n<\/ul>\n<h2>Repositories<\/h2>\n<ul>\n<li>\n<p>\u0414\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0432\u00a0<code>BaseRepository<\/code>\u00a0Kotlin \u043d\u0435 \u0432\u0438\u0434\u0438\u0442, \u043d\u0443\u0436\u043d\u043e\u00a0<a href=\"https:\/\/stackoverflow.com\/a\/77298354\/548473\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0438\u0445 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443<\/a>: \u043e\u043f\u0446\u0438\u044f\u00a0<code>-Xjvm-default=all<\/code>\u00a0\u0438\u00a0<code>@JvmDefaultWithCompatibility<\/code><\/p>\n<\/li>\n<\/ul>\n<p>\u041c\u043e\u0439 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e <a href=\"https:\/\/stackoverflow.com\/questions\/42781264\/multiple-base-repositories-in-spring-data-jpa\" rel=\"noopener noreferrer nofollow\">\u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0442\u0441\u044f \u0432\u0441\u0435 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438<\/a>:<\/p>\n<pre><code class=\"kotlin\">@NoRepositoryBean @JvmDefaultWithCompatibility interface BaseRepository&lt;T> : JpaRepository&lt;T, Int?> {     \/\/    https:\/\/docs.spring.io\/spring-data\/jpa\/docs\/current\/reference\/html\/#jpa.query.spel-expressions     @Transactional     @Modifying     @Query(\"DELETE FROM #{#entityName} e WHERE e.id=:id\")     fun delete(id: Int): Int      \/\/  https:\/\/stackoverflow.com\/a\/60695301\/548473 (existed delete code 204, not existed: 404)     fun deleteExisted(id: Int) {         if (delete(id) == 0) throw NotFoundException(\"Entity with id=$id not found\")     }      fun getExisted(id: Int): T = findById(id).orElseThrow { NotFoundException(\"Entity with id=$id not found\") } }<\/code><\/pre>\n<ul>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u043c\u044b \u043d\u0435 \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u044b \u043a <code>JpaRepository API<\/code>\u00a0, \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c Java Optional \u043d\u0430 Kotlin nullable,\u00a0<a href=\"https:\/\/typealias.com\/guides\/java-optionals-and-kotlin-nulls\/#orelsethrow\" rel=\"noopener noreferrer nofollow\">\u043f\u0435\u0440\u0435\u0443\u0447\u0438\u0432\u0430\u0435\u043c\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 nullable \u0435\u0449\u0435 \u0440\u0430\u0437<\/a> \ud83d\ude42<\/p>\n<\/li>\n<\/ul>\n<h2>\u0417\u0430\u043b\u043e\u0433\u0438\u043d\u0435\u043d\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c<\/h2>\n<ul>\n<li>\n<p>\u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\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 \u0438\u0437 \u043b\u044e\u0431\u043e\u0433\u043e \u043c\u0435\u0441\u0442\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432\u043c\u0435\u0441\u0442\u043e\u00a0<a href=\"https:\/\/kotlinlang.org\/docs\/object-declarations.html#companion-objects\" rel=\"noopener noreferrer nofollow\">companion objects<\/a>\u00a0\u0441\u0434\u0435\u043b\u0430\u043b\u00a0<a href=\"https:\/\/kotlinlang.org\/docs\/functions.html#function-scope\" rel=\"noopener noreferrer nofollow\">top-level functions<\/a>  <\/p>\n<\/li>\n<li>\n<p>\u0414\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0432\u00a0<code>authUser<\/code>\u00a0\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u00a0<a href=\"https:\/\/www.baeldung.com\/kotlin\/preconditions\" rel=\"noopener noreferrer nofollow\">Preconditions<\/a><\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u043b\u043b\u0438\u0437\u0438\u044e \u0438\u043c\u0435\u043d\u0438 \u0441\u00a0<em>org.springframework.security.core.userdetails.User<\/em>, \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e\u00a0<a href=\"https:\/\/kotlinlang.org\/docs\/packages.html#imports\" rel=\"noopener noreferrer nofollow\">import as SecurityUser<\/a><\/p>\n<\/li>\n<li>\n<p><code>AuthUser.user<\/code>\u00a0\u043f\u0440\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u0435\u0440\u0435\u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u0434\u0435\u043b\u0430\u0435\u043c \u0435\u0433\u043e\u00a0<code>var<\/code>  <\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"kotlin\">import org.springframework.security.core.userdetails.User as SecurityUser  fun safeAuthUser(): AuthUser? {     val auth = SecurityContextHolder.getContext().authentication ?: return null     val principal = auth.principal     return if (principal is AuthUser) principal else null }  fun authUser(): AuthUser = checkNotNull(safeAuthUser()) { \"No authorized user found\" }  class AuthUser(var user: User) : SecurityUser(user.email, user.password, user.roles) {     fun id() = user.id()     fun hasRole(role: Role) = user.hasRole(role)      override fun toString() = \"AuthUser:${user.id}[${user.email}]\" }<\/code><\/pre>\n<h2>\u041b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h2>\n<p>\u041d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043a\u0440\u0430\u0441\u0438\u0432\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441\u00a0\u043b\u043e\u0433\u0430\u043c\u0438 \u0447\u0435\u0440\u0435\u0437 <a href=\"https:\/\/github.com\/MicroUtils\/kotlin-logging\" rel=\"noopener noreferrer nofollow\">kotlin\u2011logging<\/a>: \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c <em>kotlin\u2011logging\u2011jvm<\/em><\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/realjenius.com\/2017\/08\/31\/logging-in-kotlin\/\" rel=\"noopener noreferrer nofollow\">Kotlin Logging Without the Fuss<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/stackoverflow.com\/questions\/57728079\/kotlin-best-way-to-log-using-slf4j\" rel=\"noopener noreferrer nofollow\">Kotlin best way to log<\/a><\/p>\n<\/li>\n<\/ul>\n<h3>\u0411\u0438\u043d\u044b Spring<\/h3>\n<ul>\n<li>\n<p> \u0414\u043b\u044f <code>@Autowired<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <a href=\"https:\/\/kotlinlang.org\/docs\/properties.html#late-initialized-properties-and-variables\" rel=\"noopener noreferrer nofollow\">\u043e\u0442\u043b\u043e\u0436\u0435\u043d\u043d\u0443\u044e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e<\/a> (<code>lateinit var<\/code> )<\/p>\n<\/li>\n<li>\n<p>\u0412\u0441\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u0438 <strong>\u043f\u0440\u043e\u043a\u0441\u0438\u0440\u0443\u0435\u0442\u0441\u044f Spring<\/strong> \u0434\u043e\u043b\u0436\u043d\u044b\u00a0\u0431\u044b\u0442\u044c <code>open<\/code> <\/p>\n<\/li>\n<\/ul>\n<h3>\u041e\u0431\u0449\u0438\u0435 \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u044f<\/h3>\n<ul>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c, \u0433\u0434\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u043e\u0435 <a href=\"https:\/\/kotlinlang.org\/docs\/control-flow.html#when-expression\" rel=\"noopener noreferrer nofollow\">\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 when<\/a>, \u0437\u0430\u043c\u0435\u043d\u0443 Java <code>Optional<\/code> \u043d\u0430 <a href=\"https:\/\/typealias.com\/guides\/java-optionals-and-kotlin-nulls\/\" rel=\"noopener noreferrer nofollow\">Kotlin Nulls<\/a> \u0438 <a href=\"https:\/\/kotlinlang.org\/docs\/properties.html#compile-time-constants\" rel=\"noopener noreferrer nofollow\">\u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438<\/a><\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <a href=\"https:\/\/kotlinlang.org\/docs\/scope-functions.html\" rel=\"noopener noreferrer nofollow\">Scope functions<\/a>, \u0432\u044b\u0431\u043e\u0440 \u043d\u0443\u0436\u043d\u043e\u0439 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u043e\u00a0\u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0435 <a href=\"https:\/\/kotlinlang.org\/docs\/scope-functions.html#function-selection\" rel=\"noopener noreferrer nofollow\">Function selection<\/a><\/p>\n<\/li>\n<li>\n<p>\u0412\u00a0Kotlin <a href=\"https:\/\/kotlinlang.org\/docs\/java-to-kotlin-interop.html#checked-exceptions\" rel=\"noopener noreferrer nofollow\">\u043d\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c\u044b\u0445 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439<\/a>, <code>@Throws<\/code> \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f\u00a0\u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438\u0437\u00a0Java <\/p>\n<\/li>\n<li>\n<p>Kotlin \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 <a href=\"https:\/\/kotlinlang.org\/docs\/extensions.html\" rel=\"noopener noreferrer nofollow\">\u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u043f\u0443\u0442\u0451\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430<\/a>, \u0447\u0442\u043e\u00a0\u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u043a\u043e\u0434 \u0435\u0449\u0435 \u0431\u043e\u043b\u0435\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e\u2011\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c (<a href=\"https:\/\/medium.com\/@y9vad9\/extension-oriented-design-6d9898c33e5f\" rel=\"noopener noreferrer nofollow\">Extension Oriented Design<\/a>). \u0421\u0442\u0430\u0440\u0430\u0439\u0442\u0435\u0441\u044c \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u044d\u0442\u043e\u0442 \u0434\u0438\u0437\u0430\u0439\u043d \u0432\u0435\u0437\u0434\u0435, \u0433\u0434\u0435 \u043a\u00a0\u043e\u0431\u044a\u0435\u043a\u0442\u0443 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430. \u0414\u043b\u044f\u00a0\u0432\u0441\u0435\u0445 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439 \u0443\u0440\u043e\u0432\u043d\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0441\u043e\u0437\u0434\u0430\u043b \u0432\u00a0\u043a\u043e\u0440\u043d\u0435\u0432\u043e\u043c \u043f\u0430\u043a\u0435\u0442\u0435 <code>Extensions.kt<\/code>  <\/p>\n<\/li>\n<li>\n<p>Kotlin \u043f\u043e\u00a0\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 getter\/setter \u0434\u043b\u044f\u00a0\u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u0435\u0439 \u043a\u043b\u0430\u0441\u0441\u0430. \u0412\u00a0\u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0433\u043e \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442, \u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 <a href=\"https:\/\/stackoverflow.com\/a\/62338482\/548473\" rel=\"noopener noreferrer nofollow\">\u0437\u0430\u043f\u0440\u0435\u0442 \u043d\u0430\u00a0\u0430\u0432\u0442\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u0447\u0435\u0440\u0435\u0437 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e @JvmField<\/a>  <\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043c\u0435\u043d\u044f\u0435\u043c Java \u043a\u043b\u0430\u0441\u0441\u044b <code>Class<\/code>  \u043d\u0430\u00a0Kotlin <a href=\"https:\/\/kotlinlang.org\/api\/latest\/jvm\/stdlib\/kotlin.reflect\/-k-class\/\" rel=\"noopener noreferrer nofollow\">KClass<\/a> \u0438 Java \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u043d\u0430 <a href=\"https:\/\/kotlinlang.org\/docs\/collections-overview.html\" rel=\"noopener noreferrer nofollow\">\u0438\u0445 Kotlin \u0430\u043d\u0430\u043b\u043e\u0433\u0438<\/a><\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0432\u00a0\u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u00a0\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u043c\u043e\u0436\u043d\u043e \u043c\u0435\u043d\u044f\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <a href=\"https:\/\/kotlinlang.org\/docs\/functions.html#named-arguments\" rel=\"noopener noreferrer nofollow\">\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440<\/a> <\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u0430\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u043a \u0435\u0449\u0435 \u0440\u0430\u0437\u00a0\u2014 \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0435\u00a0\u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0430 \u0434\u043b\u044f\u00a0\u0447\u0442\u0435\u043d\u0438\u044f. \u042d\u0442\u043e \u0441\u043a\u043e\u0440\u0435\u0435 \u043d\u0430\u0431\u043e\u0440 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0440\u0430\u0432\u0438\u043b \u0438\u0437\u00a0\u043a\u0443\u0440\u0441\u0430 Spring Boot REST API \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430\u00a0Kotlin<strong> <\/strong>(\u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043d\u0430\u0448\u0438\u0445 \u043a\u0443\u0440\u0441\u043e\u0432 \u00ab\u0418\u0437 Middle \u0432\u00a0Senior\u00bb, \u0441\u043c. \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u043f\u043e\u0441\u0442 \u043f\u043e\u00a0\u043a\u0443\u0440\u0441\u0443 <strong>&#171;<\/strong><a href=\"https:\/\/habr.com\/ru\/articles\/765332\/\" rel=\"noopener noreferrer nofollow\">\u0420\u0430\u0431\u043e\u0442\u0430 \u0441\u00a0\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u0432\u00a0Java<\/a><strong>&#171;<\/strong>)<strong> <\/strong>\u0434\u043b\u044f\u00a0\u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0441\u0432\u043e\u0435\u0433\u043e Java \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f (\u0432 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 Spring Boot), \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u0431\u0440\u0430\u0449\u0430\u0439\u0442\u0435\u0441\u044c \u043a\u00a0\u043d\u0435\u0439, \u043a\u043e\u0433\u0434\u0430 \u0440\u0435\u0448\u0438\u0442\u0435\u0441\u044c \u043d\u0430\u00a0\u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e.<\/p>\n<p>\u0418 \u0434\u0430\u00a0\u043f\u0440\u0435\u0431\u0443\u0434\u0435\u0442 \u0441\u00a0\u0432\u0430\u043c\u0438 \u0441\u0438\u043b\u0430:)!<\/p>\n<p>PS: \u0431\u0443\u0434\u0443 \u043f\u0440\u0438\u0437\u043d\u0430\u0442\u0435\u043b\u0435\u043d \u0437\u0430\u00a0\u043b\u044e\u0431\u044b\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u044f \u0438 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u043a\u00a0\u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u043a\u043e\u0434\u0430 \u043d\u0430\u00a0Kotlin.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><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\/articles\/777824\/\"> https:\/\/habr.com\/ru\/articles\/777824\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-361779","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/361779","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=361779"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/361779\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=361779"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=361779"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=361779"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}