{"id":304957,"date":"2020-06-07T09:00:24","date_gmt":"2020-06-07T09:00:24","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=304957"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2020-06-07T09:00:24","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=304957","title":{"rendered":"\u0412\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 Spring Boot \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/505628\/\">\n<p>\u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u0432\u0430\u0436\u043d\u044b\u0445 \u0448\u0430\u0433\u043e\u0432 \u0434\u043b\u044f \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0435 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0435\u0439. \u0421\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438. <\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u043d\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u043d\u0435\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b. <\/p>\n<p>  <\/p>\n<p>Spring Boot \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u043d\u0430\u043c \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438. \u041c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u043e <strong>@ConfigurationProperties<\/strong> \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/beanvalidation.org\/\" rel=\"nofollow\"><u>Bean Validation<\/u><\/a> \u0434\u043b\u044f \u0438\u0445 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h2 id=\"kod-primera\">\u041a\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u0440\u0430<\/h2>\n<p>  <\/p>\n<p>\u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0430\u0435\u0442\u0441\u044f <a href=\"https:\/\/github.com\/thombergs\/code-examples\/tree\/master\/spring-boot\/configuration\" rel=\"nofollow\"><u>\u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u0440\u0430\u0431\u043e\u0447\u0435\u0433\u043e \u043a\u043e\u0434\u0430 \u043d\u0430 GitHub<\/u><\/a>.<\/p>\n<p>  <\/p>\n<h2 id=\"zachem-nam-nuzhno-proveryat-parametry-konfiguracii\">\u0417\u0430\u0447\u0435\u043c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438?<\/h2>\n<p>  <\/p>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0439 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u043d\u0430\u0448\u0438\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0438\u043d\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c.<\/p>\n<p>  <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439:<\/p>\n<p>  <\/p>\n<p>\u041c\u044b \u043f\u0440\u043e\u0441\u044b\u043f\u0430\u0435\u043c\u0441\u044f \u0440\u0430\u043d\u043e \u0443\u0442\u0440\u043e\u043c \u043e\u0442 \u0437\u0432\u043e\u043d\u043a\u0430 \u0440\u0430\u0441\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0436\u0430\u043b\u0443\u0435\u0442\u0441\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u044b\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043d\u0430 \u0441\u0432\u043e\u044e \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u0443\u044e \u043f\u043e\u0447\u0442\u0443 \u0438\u0437 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u043e\u0433\u043e \u043d\u0430\u043c\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445. \u041c\u044b \u0432\u044b\u043f\u0440\u044b\u0433\u0438\u0432\u0430\u0435\u043c \u0438\u0437 \u043f\u043e\u0441\u0442\u0435\u043b\u0438, \u0447\u0442\u043e\u0431\u044b \u0440\u0435\u0448\u0438\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443.<\/p>\n<p>  <\/p>\n<p>\u0412 \u043a\u043e\u043d\u0446\u0435 \u043a\u043e\u043d\u0446\u043e\u0432, \u043c\u044b \u043e\u0441\u043e\u0437\u043d\u0430\u0435\u043c \u043f\u0440\u0438\u0447\u0438\u043d\u0443 \u2014 \u044d\u0442\u043e \u043e\u043f\u0435\u0447\u0430\u0442\u043a\u0430 \u0432 \u0430\u0434\u0440\u0435\u0441\u0435 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0439 \u043f\u043e\u0447\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"xml\">app.properties.report-email-address = manager.analysisapp.com<\/code><\/pre>\n<p>  <\/p>\n<p>\u00ab\u0420\u0430\u0437\u0432\u0435 \u044f \u043d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043b \u044d\u0442\u043e? \u0410 \u043d\u0443 \u043f\u043e\u043d\u044f\u0442\u043d\u043e. \u041c\u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438, \u043d\u043e \u043c\u043d\u0435 \u0431\u044b\u043b\u043e \u043e\u0447\u0435\u043d\u044c \u043b\u0435\u043d\u0438\u0432\u043e \u0432 \u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442. \u0410\u0430\u0430, \u043d\u0435 \u0432\u0430\u0436\u043d\u043e, \u044d\u0442\u043e \u0436\u0435 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043e \u0441\u0435\u0439\u0447\u0430\u0441.\u00bb<\/p>\n<p>  <\/p>\n<p>\u042f \u0436\u0438\u043b \u043f\u043e \u0442\u0430\u043a\u043e\u043c\u0443 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044e, \u043d\u0435 \u043e\u0434\u0438\u043d \u0440\u0430\u0437.<\/p>\n<p>  <\/p>\n<p>\u0418\u0442\u0430\u043a, \u0432\u043e\u0442 \u043c\u043e\u0442\u0438\u0432\u0430\u0446\u0438\u044f \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043d\u0430\u0439\u0442\u0438 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b.<\/p>\n<p>  <\/p>\n<h2 id=\"validaciya-svoystv-pri-zapuske\">\u0412\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435<\/h2>\n<p>  <\/p>\n<p><a href=\"https:\/\/reflectoring.io\/spring-boot-configuration-properties\/\" rel=\"nofollow\"><u>\u041f\u0440\u0438\u0432\u044f\u0437\u043a\u0430 \u043d\u0430\u0448\u0438\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0443<\/u><\/a> \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u0438\u0445. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, <strong><i>\u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u0432\u044b\u0433\u043e\u0434\u0443 \u0438\u0437 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u0442\u0438\u043f\u043e\u0432 \u0438 \u043d\u0430\u0439\u0442\u0438 \u043e\u0448\u0438\u0431\u043a\u0438 \u0440\u0430\u043d\u044c\u0448\u0435<\/i><\/strong>.<\/p>\n<p>  <\/p>\n<p>Spring Boot \u0438\u043c\u0435\u0435\u0442 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e <strong>@ConfigurationProperties<\/strong> \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0432 \u0444\u0430\u0439\u043b\u0430\u0445 <strong>application.properties<\/strong> \u0438\u043b\u0438 <strong>application.yml<\/strong>.<\/p>\n<p>  <\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u0434\u043b\u044f \u0438\u0445 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0435\u0449\u0435 \u043f\u0430\u0440\u0443 \u0448\u0430\u0433\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u0437\u0433\u043b\u044f\u043d\u0435\u043c \u043d\u0430 \u043d\u0430\u0448 \u0444\u0430\u0439\u043b <strong>application.properties<\/strong>:<\/p>\n<p>  <\/p>\n<pre><code class=\"xml\">app.properties.name = Analysis Application app.properties.send-report-emails = true app.properties.report-type = HTML app.properties.report-interval-in-days = 7 app.properties.report-email-address = manager@analysisapp.com<\/code><\/pre>\n<p>  <\/p>\n<p>\u0417\u0430\u0442\u0435\u043c \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e <strong>@Validated<\/strong> \u0432 \u043d\u0430\u0448 \u043a\u043b\u0430\u0441\u0441 <strong>@ConfigurationProperties<\/strong> \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f\u043c\u0438 <a href=\"https:\/\/reflectoring.io\/bean-validation-with-spring-boot\/\" rel=\"nofollow\"><u>Bean Validation<\/u><\/a> \u0432 \u043f\u043e\u043b\u044f\u0445:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">@Validated @ConfigurationProperties(prefix=&quot;app.properties&quot;) class AppProperties {    @NotEmpty   private String name;    private Boolean sendReportEmails;    private ReportType reportType;    @Min(value = 7)   @Max(value = 30)   private Integer reportIntervalInDays;    @Email   private String reportEmailAddress;    \/\/ getters \/ setters }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b Spring Boot \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043b \u043d\u0430\u0448 \u043a\u043b\u0430\u0441\u0441 <strong>AppProperties<\/strong>, \u043c\u044b \u0430\u043d\u043d\u043e\u0442\u0438\u0440\u0443\u0435\u043c \u044d\u0442\u043e\u0442 <strong>@Configuration<\/strong> \u043a\u043b\u0430\u0441\u0441 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <strong>@EnableConfigurationProperties<\/strong>:<\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u043c\u044b \u0441\u0435\u0439\u0447\u0430\u0441 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 Spring Boot \u0441 (\u043d\u0435\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c) \u0430\u0434\u0440\u0435\u0441\u043e\u043c \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0439 \u043f\u043e\u0447\u0442\u044b \u0438\u0437 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u0448\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0441\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"xml\">*************************** APPLICATION FAILED TO START ***************************  Description:  Binding to target org.springframework.boot.context.properties.bind.BindException:   Failed to bind properties under 'app.properties' to   io.reflectoring.validation.AppProperties failed:      Property: app.properties.reportEmailAddress     Value: manager.analysisapp.com     Reason: must be a well-formed email address  Action:  Update your application's configuration<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"zavisimost-api-validacii-binov\">\u0417\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c API \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0431\u0438\u043d\u043e\u0432<\/h2>\n<p>  <\/p>\n<blockquote><p>\u0427\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 bean-\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c <strong>javax.validation.validation-api<\/strong> \u0432 classpath \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p><\/blockquote>\n<p>\u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043c\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044f \u043f\u043e\u043b\u044f <strong>AppProperties<\/strong>:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">@Validated @ConfigurationProperties(prefix=&quot;app.properties&quot;) class AppProperties {   \/\/ ...   private Boolean sendReportEmails = Boolean.FALSE;    private ReportType reportType = ReportType.HTML;   \/\/ ... }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043c\u044b \u043d\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432 <strong>send-report-emails<\/strong> \u0438 <strong>report-type<\/strong> \u0432 <strong>application.properties<\/strong>, \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e <strong>Boolean.FALSE<\/strong> \u0438 <strong>ReportType.HTML<\/strong> \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e.<\/p>\n<p>  <\/p>\n<h2 id=\"validaciya-vlozhennyh-obektov-konfiguracii\">\u0412\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438<\/h2>\n<p>  <\/p>\n<p>\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0432\u043e \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442.<\/p>\n<p>  <\/p>\n<p>\u0418\u0442\u0430\u043a, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c <strong>ReportProperties<\/strong> \u0434\u043b\u044f \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u043a\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u043d\u0430\u0448\u0438\u043c \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u044b\u043c \u043e\u0442\u0447\u0435\u0442\u043e\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">class ReportProperties {    private Boolean sendEmails = Boolean.FALSE;    private ReportType type = ReportType.HTML;    @Min(value = 7)   @Max(value = 30)   private Integer intervalInDays;    @Email   private String emailAddress;    \/\/ getters \/ setters }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0417\u0430\u0442\u0435\u043c \u043c\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433 \u043d\u0430\u0448\u0438\u0445 <strong>AppProperties<\/strong>, \u0447\u0442\u043e\u0431\u044b \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0438\u0439\u0441\u044f \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 <strong>ReportProperties<\/strong> \u0432\u043c\u0435\u0441\u0442\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">@Validated @ConfigurationProperties(prefix=&quot;app.properties&quot;) class AppProperties {    @NotEmpty   private String name;    @Valid   private ReportProperties report;    \/\/ getters \/ setters }<\/code><\/pre>\n<p>  <\/p>\n<p><strong>\u041c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0438 \u043d\u0435 \u0437\u0430\u0431\u044b\u0442\u044c \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e <em><a href=\"https:\/\/habr.com\/ru\/users\/valid\/\" class=\"user_link\">Valid<\/a><\/em> \u043f\u0435\u0440\u0435\u0434 \u043d\u0430\u0448\u0438\u043c \u043f\u043e\u043b\u0435\u043c \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u043e\u0442\u0447\u0435\u0442\u0430.<\/strong><\/p>\n<p>  <\/p>\n<p>\u042d\u0442\u043e \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442 Spring, \u0447\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u0440\u0435\u0444\u0438\u043a\u0441 \u0441\u0432\u043e\u0439\u0441\u0442\u0432, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u043e\u0442\u0447\u0435\u0442\u043e\u043c, \u043d\u0430 <strong>report.*<\/strong> \u0438 \u0432 \u043d\u0430\u0448\u0435\u043c \u0444\u0430\u0439\u043b\u0435 <strong>application.properties<\/strong>:<\/p>\n<p>  <\/p>\n<pre><code class=\"xml\">... app.properties.report.send-emails = true app.properties.report.type = HTML app.properties.report.interval-in-days = 7 app.properties.report.email-address = manager@analysisapp.com<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0441 \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043e\u043c <strong>app.properties<\/strong> \u0431\u0443\u0434\u0443\u0442 \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u044b \u043a \u043a\u043b\u0430\u0441\u0441\u0443 <strong>AppProperties<\/strong>, \u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0441 \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043e\u043c <strong>app.properties.report<\/strong> \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u044b \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0443 <strong>ReportProperties<\/strong> \u0432 \u043f\u043e\u043b\u0435 <strong>report<\/strong>.<\/p>\n<p>  <\/p>\n<h2 id=\"validaciya-s-ispolzovaniem-bean-factory-methods\">\u0412\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Bean Factory Methods<\/h2>\n<p>  <\/p>\n<p>\u041c\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443, \u0441\u0432\u044f\u0437\u0430\u0432 \u0444\u0430\u0439\u043b \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0441 \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u0444\u0430\u0431\u0440\u0438\u043a\u0438 <strong><a href=\"https:\/\/habr.com\/ru\/users\/bean\/\" class=\"user_link\">Bean<\/a><\/strong> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 <strong>@ConfigurationProperties<\/strong>:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">@Configuration class AppConfiguration {   \/\/ ...   @Bean   @Validated   @ConfigurationProperties(prefix = &quot;app.third-party.properties&quot;)   public ThirdPartyComponentProperties thirdPartyComponentProperties() {     return new ThirdPartyComponentProperties();   }   \/\/ ... }<\/code><\/pre>\n<p>  <\/p>\n<p><strong>\u042d\u0442\u043e \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043a \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u043c \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u0445 \u0438\u043b\u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u043c \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 jar \u0444\u0430\u0439\u043b\u0430\u0445.<\/strong><\/p>\n<p>  <\/p>\n<h2 id=\"ispolzovanie-sobstvennogo-spring-validatora\">\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e Spring \u0432\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440\u0430<\/h2>\n<p>  <\/p>\n<p>\u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e Bean Validation \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043a \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0435 \u043d\u0430\u0448\u0438\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f, \u0438\u043d\u043e\u0433\u0434\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0434\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043d\u0430\u0448\u0435\u0439 \u043b\u043e\u0433\u0438\u043a\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u044f <strong>Spring \u0438\u043c\u0435\u0435\u0442 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u2014 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <em>Validator<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0442\u0435\u0442 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044e \u0432\u0432\u043e\u0434\u0430.<\/strong><\/p>\n<p>  <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u043c \u043d\u0430\u0448\u0443 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0447\u0442\u043e <strong>report.email-address<\/strong> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0434\u043e\u043c\u0435\u043d, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a\u043e\u0439 \u043a\u0430\u043a <strong>@<a href=\"http:\/\/analysisapp.com\/\" rel=\"nofollow\">analysisapp.com<\/a><\/strong>:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">class ReportEmailAddressValidator implements Validator {    private static final String EMAIL_DOMAIN = &quot;@analysisapp.com&quot;;    public boolean supports(Class clazz) {     return ReportProperties.class.isAssignableFrom(clazz);   }    public void validate(Object target, Errors errors) {      ValidationUtils.rejectIfEmptyOrWhitespace(errors,         &quot;emailAddress&quot;, &quot;field.required&quot;);      ReportProperties reportProperties = (ReportProperties) target;     if (!reportProperties.getEmailAddress().endsWith(EMAIL_DOMAIN)) {       errors.rejectValue(&quot;emailAddress&quot;, &quot;field.domain.required&quot;,           new Object[]{EMAIL_DOMAIN},           &quot;The email address must contain [&quot; + EMAIL_DOMAIN + &quot;] domain.&quot;);     }   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0417\u0430\u0442\u0435\u043c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448 Spring \u0432\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0441 \u0438\u043c\u0435\u043d\u0435\u043c <strong>configurationPropertiesValidator()<\/strong>:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">@Configuration class AppConfiguration {   \/\/ ...   @Bean   public static ReportEmailAddressValidator configurationPropertiesValidator() {     return new ReportEmailAddressValidator();   }   \/\/ ... }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u0438\u043c\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0435\u0433\u043e\u0441\u044f bean-\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 Spring \u0431\u0443\u0434\u0435\u0442 <strong>ConfigurationPropertiesValidator<\/strong>, Spring \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0432\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 bean-\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0441 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0435\u0439 <strong>@ConfigurationProperties<\/strong>.<\/p>\n<p>  <\/p>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430\u0448 \u043c\u0435\u0442\u043e\u0434 <strong>configurationPropertiesValidator()<\/strong> \u043a\u0430\u043a \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 Spring \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c bean-\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0440\u0430\u043d\u043d\u0435\u043c \u044d\u0442\u0430\u043f\u0435, \u043f\u0435\u0440\u0435\u0434 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 \u0441 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0435\u0439 <strong>@Configuration<\/strong>, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0434\u0440\u0443\u0433\u0438\u0445 bean-\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438.<\/p>\n<p>  <\/p>\n<h2 id=\"validator-spring-ne-yavlyaetsya-chastyu-bean-validation\">\u0412\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440 Spring \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e Bean Validation<\/h2>\n<p>  <\/p>\n<blockquote><p><a href=\"https:\/\/docs.spring.io\/spring\/docs\/current\/javadoc-api\/org\/springframework\/validation\/Validator.html\" rel=\"nofollow\"><u>\u0412\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440 Spring<\/u><\/a> \u043d\u0435 \u0441\u0432\u044f\u0437\u0430\u043d \u0441 Bean Validation \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043f\u043e\u0441\u043b\u0435 Bean Validation. \u0415\u0433\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0446\u0435\u043b\u044c \u2014 \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043e\u0442 \u043b\u044e\u0431\u043e\u0439 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0438\u043b\u0438 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430.<\/p><\/blockquote>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0432\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440\u0430 \u0434\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438, \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043f\u0443\u0442\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0444\u0430\u0431\u0440\u0438\u043a\u0438 bean-\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d bean-\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0441 \u0438\u043c\u0435\u043d\u0435\u043c <strong>configurationPropertiesValidator<\/strong>.<\/p>\n<p>  <\/p>\n<p>\u0412\u043c\u0435\u0441\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u0430 \u0444\u0430\u0431\u0440\u0438\u043a\u0438 \u0431\u0438\u043d\u043e\u0432 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u043d\u0430\u0448\u0443 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e <strong>Validator<\/strong> \u0432\u043d\u0443\u0442\u0440\u044c \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">@Validated @ConfigurationProperties(prefix = &quot;app.properties&quot;) class AppProperties implements Validator {    \/\/ properties ...    public boolean supports(Class clazz) {     return ReportProperties.class.isAssignableFrom(clazz);   }    public void validate(Object target, Errors errors) {     \/\/ validation logic   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 <strong>Validator<\/strong> \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 <strong>@ConfigurationProperties<\/strong>.<\/p>\n<p>  <\/p>\n<h2 id=\"zaklyuchenie\">\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0438\u0442\u044c \u0441\u0435\u0431\u044f \u043e\u0442 \u043e\u0448\u0438\u0431\u043e\u043a \u0432\u0432\u043e\u0434\u0430, \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430\u0448\u0435\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u2014 \u044d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0441\u043f\u043e\u0441\u043e\u0431. Spring Boot \u043e\u0431\u043b\u0435\u0433\u0447\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u043c\u0438 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435.<\/p>\n<p>  <\/p>\n<p>\u0412\u0441\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043a\u043e\u0434\u0430, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0438\u0433\u0440\u0430\u0442\u044c, \u0438 \u0434\u0430\u0436\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u043c\u0435\u0435\u0442\u0441\u044f <a href=\"https:\/\/github.com\/thombergs\/code-examples\/tree\/master\/spring-boot\/configuration\" rel=\"nofollow\"><u>\u043d\u0430 Github<\/u><\/a> .<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/505628\/\"> https:\/\/habr.com\/ru\/post\/505628\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/505628\/\">\n<p>\u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u0432\u0430\u0436\u043d\u044b\u0445 \u0448\u0430\u0433\u043e\u0432 \u0434\u043b\u044f \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0435 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0435\u0439. \u0421\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438. <\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u043d\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u043d\u0435\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b. <\/p>\n<p>  <\/p>\n<p>Spring Boot \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u043d\u0430\u043c \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438. \u041c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u043e <strong>@ConfigurationProperties<\/strong> \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/beanvalidation.org\/\" rel=\"nofollow\"><u>Bean Validation<\/u><\/a> \u0434\u043b\u044f \u0438\u0445 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438.<\/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-304957","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/304957","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=304957"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/304957\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=304957"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=304957"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=304957"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}