{"id":380143,"date":"2024-06-27T15:01:00","date_gmt":"2024-06-27T15:01:00","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=380143"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=380143","title":{"rendered":"<span>Spring Boot Starter: \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438, \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0438\u0430\u043b\u044c\u043d\u043e \u0438 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e. Part 2<\/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<h3>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440! \u041d\u0430 \u0441\u0432\u044f\u0437\u0438 \u0441\u043d\u043e\u0432\u0430 \u0421\u0435\u0440\u0433\u0435\u0439 \u0421\u043e\u043b\u043e\u0432\u044b\u0445, Java-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u041c\u0422\u0421 Digital. <\/h3>\n<p>\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044e \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043e Spring Boot Starter. \u0412 <a href=\"https:\/\/habr.com\/ru\/companies\/ru_mts\/articles\/811693\/\">\u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0447\u0430\u0441\u0442\u0438<\/a> \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0442\u0430\u0440\u0442\u0435\u0440 \u043a\u0430\u043a \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0443\u044e \u043a \u0434\u0440\u0443\u0433\u043e\u043c\u0443 Spring-Boot-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f \u0441 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438, \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c\u0438 \u0438 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u043c\u0438 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f\u043c\u0438. <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d59\/caf\/531\/d59caf531066c07b9f43edd1da38d898.png\" width=\"1920\" height=\"1080\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d59\/caf\/531\/d59caf531066c07b9f43edd1da38d898.png\"\/><\/figure>\n<h2>\u0417\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438<\/h2>\n<p>\u0421\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u043d\u0430\u043c\u0438 \u043a\u0430\u0440\u043a\u0430\u0441 Spring-Boot-\u0441\u0442\u0430\u0440\u0442\u0435\u0440\u0430 \u0431\u044b\u043b \u043d\u0435\u043f\u043b\u043e\u0445 \u0434\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043e\u0431\u0449\u0438\u0445 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u0432 \u0438 \u0437\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u0430 \u0441 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0438\u0430\u043b\u044c\u043d\u044b\u043c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e\u043c. \u041d\u043e \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043f\u0435\u0440\u0435\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0435\u0433\u043e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443. \u041c\u044b \u0440\u0435\u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0443\u0435\u043c \u0444\u0430\u0431\u0440\u0438\u043a\u0438: \u0442\u0435\u043f\u0435\u0440\u044c \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0442\u044c\u0441\u044f \u043d\u0435 \u043f\u043e \u0442\u0438\u043f\u0430\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 (\u0436\u0438\u0432\u043e\u0442\u043d\u044b\u0435 \u0438 \u043c\u0435\u0441\u0442\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044f), \u0430 \u043f\u043e \u043f\u0440\u043e\u0444\u0438\u043b\u044e \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0431\u0438\u0442\u0430\u0442\u0435\u043b\u044f. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u043d\u043a\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443.<\/p>\n<p>\u041a\u0430\u0436\u0434\u0443\u044e \u0444\u0430\u0431\u0440\u0438\u043a\u0443 \u043d\u0430\u0437\u043e\u0432\u0435\u043c \u043f\u043e \u0438\u043c\u0435\u043d\u0438 \u043e\u0431\u0438\u0442\u0430\u0442\u0435\u043b\u044f \u0438 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0435\u043c \u0442\u0443\u0434\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0438\u0442\u043e\u043c\u0446\u0430 \u0438 \u0432\u043e\u043b\u044c\u0435\u0440\u044b \u0434\u043b\u044f \u043d\u0435\u0433\u043e:<\/p>\n<pre><code class=\"java\">@AutoConfiguration(\"napoleonFactory\") public class NapoleonFactory {     @Bean    public Napoleon napoleon() {        return new Napoleon();    }     @Bean    public Lawn lawn(Napoleon napoleon) {        return new Lawn(napoleon);    } }<\/code><\/pre>\n<p>\u041e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0435\u0441\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u0435: \u041d\u0430\u043f\u043e\u043b\u0435\u043e\u043d \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0447\u0442\u043e-\u0442\u043e \u0436\u0443\u0435\u0442, \u0438 \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043c\u043e\u0433 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u043a\u043e\u0441\u043c\u043e\u0437\u043e\u043e\u043f\u0430\u0440\u043a\u0435, \u043d\u0430 \u0435\u0433\u043e \u0442\u0435\u0440\u0440\u0438\u0442\u043e\u0440\u0438\u0438 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043e\u0433\u043e\u0440\u043e\u0434 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u043e\u0432\u043e\u0449\u0430\u043c\u0438. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043b\u0430\u0441\u0441 <strong>Garden:<\/strong><\/p>\n<pre><code class=\"java\">@RequiredArgsConstructor public class Lawn {     private final Napoleon napoleon;     public static class Garden { \/\/code    } }<\/code><\/pre>\n<p>\u0418 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0435\u0433\u043e \u0432 \u0444\u0430\u0431\u0440\u0438\u043a\u0443:<\/p>\n<pre><code class=\"java\">@AutoConfiguration(\"napoleonFactory\") public class NapoleonFactory {     @Bean    public Napoleon napoleon() {        System.out.println(\"Napoleon created\");        return new Napoleon();    }     @Bean    public Lawn.Garden garden() {        System.out.println(\"Garden created\");        return new Lawn.Garden();    }     @Bean    public Lawn lawn(Napoleon napoleon) {        System.out.println(\"Lawn created\");        return new Lawn(napoleon);    } }<\/code><\/pre>\n<p>\u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0442\u0435\u0441\u0442 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438:<\/p>\n<pre><code class=\"java\">@SpringBootTest(classes = NapoleonFactory.class) class NapoleonFactoryTest {     @Autowired    private ApplicationContext context;     @ParameterizedTest    @MethodSource(\"beanNames\")    void applicationContextContainsBean(String beanName) {        Assertions.assertTrue(context.containsBean(beanName));    }     private static Stream&lt;String> beanNames() {        return Stream.of(                \"napoleonFactory\",                \"napoleon\",                \"garden\",                \"lawn\"        );    } }<\/code><\/pre>\n<p>\u0412\u0441\u0435 \u0431\u0438\u043d\u044b \u0441\u043e\u0437\u0434\u0430\u043d\u044b, \u043d\u043e \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u2014 \u0432\u044b\u0432\u043e\u0434 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0438\u0445 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f:<\/p>\n<pre><code class=\"java\">Napoleon created Garden created Lawn created<\/code><\/pre>\n<p>\u041a\u0430\u043a \u043f\u0435\u0440\u0435\u0434 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435\u043c \u041d\u0430\u043f\u043e\u043b\u0435\u043e\u043d\u0430 \u043d\u0430\u043c \u0431\u044b\u0442\u044c \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u043c\u0438, \u0447\u0442\u043e \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u043e\u0433\u043e\u0440\u043e\u0434? \u0422\u0443\u0442 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u043e\u0447\u044c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f <strong>@DependsOn.<\/strong> \u041a\u0430\u043a \u0433\u043b\u0430\u0441\u0438\u0442 <strong>javadoc<\/strong> \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 <strong>@DependsOn<\/strong>, \u043e\u043d\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u043c\u0435\u043d \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432, \u043e\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043d\u0430\u0448 <strong>bean<\/strong>. \u0410 \u0435\u0449\u0435 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442, \u0447\u0442\u043e:<\/p>\n<ul>\n<li>\n<p>\u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u044b \u0434\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 <strong>bean&#8217;\u0430<\/strong><\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430<strong> bean&#8217;\u0430<\/strong>, \u0430 \u043f\u043e\u0442\u043e\u043c \u0435\u0433\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0443\u043a\u0430\u0436\u0435\u043c, \u0447\u0442\u043e \u043e\u0431\u044a\u0435\u043a\u0442 <strong>&#171;napoleon&#187;<\/strong> \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 <strong>&#171;garden&#187;<\/strong>, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442, \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d \u043f\u043e\u0441\u043b\u0435 \u043d\u0435\u0433\u043e:<\/p>\n<pre><code class=\"java\">@Bean @DependsOn(\"garden\") public Napoleon napoleon() {    System.out.println(\"Napoleon created\");    return new Napoleon(); }<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0442\u0435\u0441\u0442 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0432\u044b\u0432\u043e\u0434 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c:<\/p>\n<pre><code class=\"java\">Garden created Napoleon created Lawn created<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u0441\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e. \u0423\u0441\u043b\u043e\u0432\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442, \u0447\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u0435 \u0431\u0438\u043d\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0443\u0442\u0441\u044f. \u0418\u043d\u0430\u0447\u0435, \u0435\u0441\u043b\u0438 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 &#171;<strong>garden<\/strong>&#171;, \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0443\u043f\u0430\u0434\u0435\u0442 \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439 NoSuchBeanDefinitionException. <\/p>\n<h2>\u0423\u0441\u043b\u043e\u0432\u0438\u044f<\/h2>\n<h3>\u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438<\/h3>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 <a href=\"https:\/\/docs.spring.io\/spring-boot\/docs\/current\/reference\/htmlsingle\/#features.developing-auto-configuration.condition-annotations\"><strong>@ConditionOn<\/strong><\/a> \u043e\u0442 <strong>@DependsOn<\/strong> \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043d\u0435\u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u043d\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442 \u043a \u043e\u0448\u0438\u0431\u043a\u0435 \u0441\u0442\u0430\u0440\u0442\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d \u0431\u0438\u043d \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430. \u0422\u0430\u043a\u0436\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0431\u043e\u043b\u0435\u0435 \u0433\u0438\u0431\u043a\u0438\u0435 \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u0435\u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440.<\/p>\n<h3>@ConditionalOnProperty<\/h3>\n<p>\u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043f\u0440\u0435\u0434\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438. \u0421 \u0438\u0445 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0438\u043b\u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0432 \u0444\u0430\u0439\u043b\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438. \u042d\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430-\u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0438 \u043d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439, \u0435\u0441\u043b\u0438 \u0432 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0438\u043b\u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u0441\u0435\u0440\u0432\u0438\u0441. <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0412\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a \u043d\u0430\u0448\u0435\u043c\u0443 \u043f\u0440\u0438\u043c\u0435\u0440\u0443. \u0412\u044b\u044f\u0441\u043d\u0438\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0434\u0435\u0442\u0441\u043a\u0438\u0445 \u044d\u043a\u0441\u043a\u0443\u0440\u0441\u0438\u0439 \u0432 \u0437\u043e\u043e\u043f\u0430\u0440\u043a \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0435\u0442\u0438 \u043f\u0443\u0433\u0430\u044e\u0442\u0441\u044f \u0442\u0438\u0433\u0440\u043e\u043a\u0440\u044b\u0441\u0430 \u2014 \u0443\u0436 \u0431\u043e\u043b\u044c\u043d\u043e \u0441\u0432\u0438\u0440\u0435\u043f\u044b\u043c \u043e\u043d \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442. \u0422\u0430\u043a \u0447\u0442\u043e \u0431\u044b\u043b\u043e \u0440\u0435\u0448\u0435\u043d\u043e \u043d\u0435 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u0434\u043d\u0438 \u044d\u043a\u0441\u043a\u0443\u0440\u0441\u0438\u0439 \u043c\u0430\u043b\u044b\u0448\u0435\u0439. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043d\u0430\u0448\u0435\u0433\u043e \u0437\u043e\u043e\u043f\u0430\u0440\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0438 \u0432\u044b\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e \u0436\u0438\u0432\u043e\u0442\u043d\u043e\u0433\u043e. \u0412 \u0444\u0430\u0439\u043b <strong>application.properties<\/strong> \u0432\u043d\u0435\u0441\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440:<\/p>\n<pre><code class=\"java\">app.tigrokris.create=false<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0431\u0440\u0438\u043a\u0443 \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0442\u0430\u043c \u0434\u0430\u043d\u043d\u0443\u044e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e:<\/p>\n<pre><code class=\"java\">@Bean @ConditionalOnProperty(        value = \"app.tigrokris.create\",        havingValue = \"true\",        matchIfMissing = false ) public Tigrokris tigrokris() {    return new Tigrokris(); }<\/code><\/pre>\n<p>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <strong>value = &#171;app.tigrokris.create&#187;<\/strong> \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430. <strong>havingValue = &#171;true&#187;<\/strong> \u2014 \u044d\u0442\u043e \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u044f. <strong>matchIfMissing = false<\/strong> \u2014 \u044d\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430.<\/p>\n<h3>@ConditionalOnBean \u0438 @ConditionalOnMissingBean<\/h3>\n<p>\u0410\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f <strong>@ConditionalOnBean<\/strong> \u0434\u0438\u043a\u0442\u0443\u0435\u0442 \u0443\u0441\u043b\u043e\u0432\u0438\u044f, \u0447\u0442\u043e \u0431\u0438\u043d \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d, \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0435\u0441\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0438\u043b\u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f. \u041f\u0440\u0438\u043c\u0435\u043d\u044f\u044f <strong>@ConditionalOnMissingBean,<\/strong> \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435: \u0431\u0438\u043d \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430. \u042d\u0442\u0438 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u0435\u0437\u043d\u044b \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0439 \u0434\u043b\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0441\u0440\u0435\u0434 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u0430 \u0435\u0449\u0435 \u0434\u043b\u044f \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\u0438.<\/p>\n<p>\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0431\u044b\u043b\u0430 \u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f, \u0447\u0442\u043e \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445 \u0431\u0438\u043d \u043a\u043b\u0430\u0441\u0441\u0430 <strong>Tigrokris<\/strong> \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d. \u041d\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0443\u043f\u0430\u0441\u0442\u044c \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439 \u2014 \u044d\u0442\u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0432\u043e\u043b\u044c\u0435\u0440\u0430. \u041c\u043e\u0436\u043d\u043e, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0438 \u0442\u0443\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c <strong>@ConditionalOnProperty <\/strong>\u0441 \u0442\u0435\u043c \u0436\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435\u043c, \u043d\u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0431\u0443\u0434\u0435\u0442 \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u0431\u0438\u043d\u0430 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435. \u0422\u043e \u0435\u0441\u0442\u044c \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u0431\u0438\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0438\u043b\u0438 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0442\u044c\u0441\u044f \u043a\u043b\u0435\u0442\u043a\u0430 \u0434\u043b\u044f \u0442\u0438\u0433\u0440\u043e\u043a\u0440\u044b\u0441\u0430. \u0412\u043e\u0442 \u0442\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432\u0441\u044f \u0444\u0430\u0431\u0440\u0438\u043a\u0430 \u0446\u0435\u043b\u0438\u043a\u043e\u043c:<\/p>\n<pre><code class=\"java\">@AutoConfiguration(\"tigrokrisFactory\") public class TigrokrisFactory {     @Bean    @ConditionalOnProperty(            value = \"app.tigrokris.create\",            havingValue = \"true\",            matchIfMissing = false    )    public Tigrokris tigrokris() {        return new Tigrokris();    }     @Bean    @ConditionalOnBean(name = \"tigrokris\")    public ClosedEnclosure closedEnclosure(Tigrokris tigrokris) {        return new ClosedEnclosure(tigrokris);    } }<\/code><\/pre>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0442\u0435\u0441\u0442:<\/p>\n<pre><code class=\"java\">@SpringBootTest(classes = TigrokrisFactory.class) class TigrokrisFactoryTest {     @Autowired    private ApplicationContext context;     @ParameterizedTest    @MethodSource(\"beanNames\")    void applicationContextContainsBean(String beanName, boolean expected) {        Assertions.assertEquals(expected, context.containsBean(beanName));    }     private static Stream&lt;Arguments> beanNames() {        return Stream.of(                Arguments.of(\"tigrokrisFactory\", true),                Arguments.of(\"tigrokris\", false),                Arguments.of(\"closedEnclosure\", false)        );    } }<\/code><\/pre>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0440\u0430\u0437\u0443 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0438\u043c \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043d\u0430 \u0432\u0441\u0435 \u0432\u043e\u043b\u044c\u0435\u0440\u044b.<\/p>\n<h3>@ConditionalOnResource<\/h3>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u0430. \u042d\u0442\u043e\u0439 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043b\u043e\u0433\u0433\u0435\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u2014 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a\u043e\u0439 \u0444\u0430\u0439\u043b \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d \u0432 classpath (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, logback.xml). <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u044d\u0442\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043a \u0428\u0443\u0448\u0435. \u0428\u0443\u0448\u0430 \u2014 \u043b\u0438\u0447\u043d\u043e\u0441\u0442\u044c \u0442\u0432\u043e\u0440\u0447\u0435\u0441\u043a\u0430\u044f. \u041b\u0443\u043d\u043d\u044b\u043c\u0438 \u043d\u043e\u0447\u0430\u043c\u0438 \u043e\u043d \u043b\u044e\u0431\u0438\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0442\u0438\u0445\u0438. \u0418 \u0440\u044f\u0434\u043e\u043c \u0432\u0441\u0435\u0433\u0434\u0430 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0431\u043b\u043e\u043a\u043d\u043e\u0442, \u043a\u0443\u0434\u0430 \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u043e, \u0447\u0442\u043e \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u0430\u043b\u0430 \u0435\u043c\u0443 \u043c\u0443\u0437\u0430. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0439\u043b <strong>notebook.txt <\/strong>\u0438 \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u043c \u0435\u0433\u043e \u0432 \u043f\u0430\u043f\u043a\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432. \u0424\u0430\u0431\u0440\u0438\u043a\u0430 \u043f\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0442\u0438\u043f\u0430 <strong>Shusha<\/strong> \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"java\">@AutoConfiguration(\"shushaFactory\") public class ShushaFactory {     @Bean    @ConditionalOnResource(resources = \"classpath:notebook.txt\")    public Shusha shusha() {        return new Shusha();    }     @Bean    @ConditionalOnBean(name = \"shusha\")    public Park park(Shusha shusha) {        return new Park(shusha);    } }<\/code><\/pre>\n<p>\u041f\u043e\u0442\u043e\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0442\u0435\u0441\u0442:<\/p>\n<pre><code class=\"java\">@SpringBootTest(classes = ShushaFactory.class) class ShushaFactoryTest {     @Autowired    private ApplicationContext context;     @ParameterizedTest    @MethodSource(\"beanNames\")    void applicationContextContainsBean(String beanName) {        Assertions.assertTrue(context.containsBean(beanName));    }     private static Stream&lt;String> beanNames() {        return Stream.of(                \"shushaFactory\",                \"shusha\",                \"park\"        );    } }<\/code><\/pre>\n<h3>@ConditionalOnExpression<\/h3>\n<p>\u042d\u0442\u0430 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043a\u0430\u043a \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f SpEL-\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u044e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u044f \u043e\u0431\u044a\u0435\u043a\u0442-\u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043c\u0435\u0441\u0442\u0438\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439, \u043d\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0439 \u0432 \u044d\u0442\u043e\u043c \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0438 \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0438\u0441 \u0441 \u043d\u0443\u0436\u043d\u044b\u043c\u0438 \u043d\u0430\u043c \u0434\u0430\u043d\u043d\u044b\u043c\u0438: &#171;${app.web.stub.enabled} and ${app.web.mock.data}&#187;.<\/p>\n<p>\u0421\u0438\u043d\u0438\u0439, \u043a\u0430\u043a \u0438 \u0432\u0441\u0435 \u0440\u0435\u043f\u0442\u0438\u043b\u0438\u0438, \u043e\u0447\u0435\u043d\u044c \u043b\u044e\u0431\u0438\u0442 \u0433\u0440\u0435\u0442\u044c\u0441\u044f \u043d\u0430 \u043f\u0435\u0441\u043e\u0447\u043a\u0435 \u0432 \u044f\u0441\u043d\u0443\u044e \u0442\u0435\u043f\u043b\u0443\u044e \u043f\u043e\u0433\u043e\u0434\u0443. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0434\u0432\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"java\">app.sun.is-shining=true app.weather=clear<\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0443 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0431\u0443\u043b\u0435\u0432\u043e, \u0430 \u0443 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u2014 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u043e\u0435. \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u044d\u0442\u0438\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Spring Expression Language:<\/p>\n<pre><code class=\"java\">@AutoConfiguration(\"siniiFactory\") public class SiniiFactory {  @Bean @ConditionalOnExpression(\"${app.sun.is-shining} and '${app.weather}'.equals('clear')\") public Sinii sinii() {    return new Sinii(); }     @Bean    @ConditionalOnBean(name = \"sinii\")    public Swamp swamp(Sinii sinii) {        return new Swamp(sinii);    } }<\/code><\/pre>\n<p>\u041c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u0432\u0441\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f, \u0438 \u0421\u0438\u043d\u0438\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0434\u043e\u0432\u043e\u043b\u0435\u043d. \u0414\u0430\u043b\u044c\u0448\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430:<\/p>\n<pre><code class=\"java\">@SpringBootTest(classes = SiniiFactory.class) class SiniiFactoryTest {     @Autowired    private ApplicationContext context;     @ParameterizedTest    @MethodSource(\"beanNames\")    void applicationContextContainsBean(String beanName) {        Assertions.assertTrue(context.containsBean(beanName));    }     private static Stream&lt;String> beanNames() {        return Stream.of(                \"siniiFactory\",                \"sinii\",                \"swamp\"        );    } }<\/code><\/pre>\n<h3>@ConditionalOnJava<\/h3>\n<p>\u041b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u0430\u044f \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0435\u0433\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0432\u0435\u0440\u0441\u0438\u0438 Java. \u042d\u0442\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0434\u043b\u044f \u0441\u043e\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0439 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0443\u043a\u0430\u0436\u0435\u043c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 java 1.7 \u0438 \u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u043d\u043d\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u0439. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e <strong>@ConditionalOnJava, <\/strong>\u0443\u043a\u0430\u0437\u0430\u0432 \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u0445 \u0432\u0435\u0440\u0441\u0438\u044e java \u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"java\">@ConditionalOnJava(value = JavaVersion.EIGHT, range = OLDER_THAN) public class CosmoZooLegacy {     @PostConstruct    private void greeting() {        System.out.println(\"\u0421\u0442\u0430\u0440\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f CosmoZoo\");    } }<\/code><\/pre>\n<p>\u041d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0433\u043e \u0432 <strong>spring.factories<\/strong>. \u0410 \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435 <strong>CosmoZoo<\/strong> \u043d\u0430\u043c \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u0435 <strong>@ConditionalOnMissingBean<\/strong>:<\/p>\n<pre><code class=\"java\">@ConditionalOnMissingBean(CosmoZooLegacy.class) public class CosmoZoo { \/\/code }<\/code><\/pre>\n<p>\u0412\u043d\u0435\u0441\u0435\u043c \u043f\u0440\u0430\u0432\u043a\u0443 \u0432 \u0442\u0435\u0441\u0442:<\/p>\n<pre><code class=\"java\">@SpringBootTest class CosmoZooTest {     @Autowired    private ApplicationContext context;     @ParameterizedTest    @MethodSource(\"beanNames\")    void applicationContextContainsBean(String beanName, boolean expected) {        Assertions.assertEquals(expected, context.containsBean(beanName));    }     private static Stream&lt;Arguments> beanNames() {        return Stream.of(                Arguments.of(\"science.zoology.CosmoZoo\", true),                Arguments.of(\"science.zoology.CosmoZooLegacy\", false)        );    }     @SpringBootApplication    public static class TestApplication {        \/\/no-op    } }<\/code><\/pre>\n<p>\u041a\u0440\u043e\u043c\u0435 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438, \u043c\u043e\u0436\u043d\u043e \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044c \u0435\u0449\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u043a \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044e \u00ab\u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438\u00bb. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043a\u0440\u0430\u0442\u043a\u043e \u043f\u043e \u043d\u0438\u043c \u043f\u0440\u043e\u0431\u0435\u0436\u0438\u043c\u0441\u044f:<\/p>\n<ul>\n<li>\n<p><strong>@ConditionalOnClass <\/strong>\u0438<strong> @ConditionalOnMissingClass<\/strong> \u2014 \u0443\u0441\u043b\u043e\u0432\u0438\u044f, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0449\u0438\u0435 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0432 classpath<\/p>\n<\/li>\n<li>\n<p><strong>@ConditionalOnSingleCandidate<\/strong> \u2014 \u044d\u0442\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u0442, \u0447\u0442\u043e\u0431\u044b \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0431\u044b\u043b \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0431\u0438\u043d \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430<\/p>\n<\/li>\n<li>\n<p><strong>@ConditionalOnWebApplication<\/strong> \u0438 <strong>@ConditionalOnNotWebApplication<\/strong> \u2014 \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e, \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u2014 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0438\u043b\u0438 \u043d\u0435\u0442<\/p>\n<\/li>\n<\/ul>\n<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0435\u0449\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439 \u0442\u0438\u043f\u0430 @Conditional, \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u044f\u043c\u0438 Spring&#8217;\u0430 \u0438 \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e. \u0418\u0445 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438.<\/p>\n<h3>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f<\/h3>\n<p>\u041a\u0440\u043e\u043c\u0435 <a href=\"https:\/\/docs.spring.io\/spring-boot\/docs\/current\/reference\/htmlsingle\/#features.developing-auto-configuration.condition-annotations\">\u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u0439<\/a>, \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0432\u043e\u0438. \u041d\u0430\u0441\u0442\u0440\u043e\u0438\u043c \u0441 \u0438\u0445 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0434\u043b\u044f \u0440\u043e\u0431\u043e\u0442\u043e\u0432, \u0443\u0445\u0430\u0436\u0438\u0432\u0430\u044e\u0449\u0438\u0445 \u0437\u0430 \u043f\u0438\u0442\u043e\u043c\u0446\u0430\u043c\u0438 \u0438 \u0437\u043e\u043e\u043f\u0430\u0440\u043a\u043e\u043c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0440\u043e\u0431\u043e\u0442-\u0443\u0431\u043e\u0440\u0449\u0438\u043a \u0434\u043e\u043b\u0436\u0435\u043d \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 \u0434\u043d\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u0447\u0438\u0441\u0442\u043e\u0442\u0443. \u041e\u043f\u0438\u0448\u0435\u043c \u044d\u0442\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u2014 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043b\u0430\u0441\u0441, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <strong>Condition<\/strong>:<\/p>\n<pre><code class=\"java\">public class TimeCondition implements Condition {     @Override    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {        String start = context.getEnvironment().getProperty(\"app.cleaning.start\");        String end = context.getEnvironment().getProperty(\"app.cleaning.end\");         int currentHour = LocalDateTime.now().getHour();        return Integer.parseInt(start) &lt;= currentHour &amp;&amp; currentHour &lt;= Integer.parseInt(end);    } }<\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0432 application.properties:<\/p>\n<pre><code class=\"java\">app.cleaning.start=10 app.cleaning.end=18<\/code><\/pre>\n<p>\u0418 \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u043c\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u0440\u043e\u0431\u043e\u0442\u0430-\u0443\u0431\u043e\u0440\u0449\u0438\u043a\u0430:<\/p>\n<pre><code class=\"java\">public class Cleaner {     public void doWork() {        \/\/code    } }<\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u043c RobotFactory:<\/p>\n<pre><code class=\"java\">@AutoConfiguration(\"robotFactory\") public class RobotFactory {     @Bean    @Conditional(TimeCondition.class)    public CleaningRobot cleaningRobot() {        return new CleaningRobot();    } }<\/code><\/pre>\n<h3>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0447\u0435\u0440\u0435\u0437 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e<\/h3>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u043e, \u043d\u0430\u043f\u0438\u0441\u0430\u0432 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0440\u043e\u0431\u043e\u0442\u0430-\u0444\u043e\u043a\u0443\u0441\u043d\u0438\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u043c \u0440\u0430\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u043f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u0435\u0439:<\/p>\n<pre><code class=\"java\">public class Magician {     public void doWork() {        \/\/code    } }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 Condition:<\/p>\n<pre><code class=\"java\">public class DayOfWeekCondition implements Condition {     @Override    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {        int dayOfWeekNumber = LocalDateTime.now().get(DAY_OF_WEEK);         return dayOfWeekNumber > 5;    } }<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u043d\u0435\u0441\u0435\u043c \u044d\u0442\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0432 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e:<\/p>\n<pre><code class=\"java\">@Retention(RUNTIME) @Conditional(DateCondition.class) public @interface ConditionalOnDayOfWeek { }<\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u0431\u0438\u043d\u0430:<\/p>\n<pre><code class=\"java\">@Bean @ConditionalOnDayOfWeek public Magician magician() {    return new Magician(); }<\/code><\/pre>\n<h3>\u0421\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u0439<\/h3>\n<h3>AND<\/h3>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0431\u043b\u044e\u0441\u0442\u0438 \u0434\u0432\u0430 \u0438 \u0431\u043e\u043b\u0435\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0439, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0438\u0445 \u043d\u0430\u0434 \u043d\u0443\u0436\u043d\u044b\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u043c:<\/p>\n<pre><code class=\"java\">@Bean @Conditional(TimeCondition.class) @ConditionalOnDayOfWeek public MyBean myBean() {  return new MyBean(); }<\/code><\/pre>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0431\u044a\u0435\u043a\u0442 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u043e\u0431\u0430 \u0443\u0441\u043b\u043e\u0432\u0438\u044f: \u044d\u0442\u043e \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u043d\u0438 \u0438 \u0432\u0440\u0435\u043c\u044f \u0432 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435. \u041d\u043e \u0435\u0441\u043b\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u043c\u043d\u043e\u0433\u043e, \u0443\u0434\u043e\u0431\u043d\u0435\u0435 \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0438\u0445 \u0432 \u043e\u0434\u043d\u043e. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441, \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043e\u0442 <strong>AllNestedConditions<\/strong> \u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0432 \u043d\u0435\u043c \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f:<\/p>\n<pre><code class=\"java\">public class TimeAndDayOfWeekConditions extends AllNestedConditions {     public TimeAndDayOfWeekConditions() {        super(ConfigurationPhase.REGISTER_BEAN);    }     @Conditional(TimeCondition.class)    static class OnTimeCondition {    }     @ConditionalOnDayOfWeek    static class OnDayOfWeekCondition {    } }<\/code><\/pre>\n<p>\u041f\u043e\u0442\u043e\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e:<\/p>\n<pre><code class=\"java\">@Retention(RetentionPolicy.RUNTIME) @Conditional(TimeAndDayOfWeekConditions.class) public @interface ConditionalOnTimeAndDayOfWeek { }<\/code><\/pre>\n<p>\u0418 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0435\u0435 \u0432 \u043d\u0430\u0448\u0435\u0439 \u0444\u0430\u0431\u0440\u0438\u043a\u0435 \u2014 \u043f\u0443\u0441\u0442\u044c \u043f\u043e \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u043c \u0432 \u0434\u043d\u0435\u0432\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043b\u0430\u0432\u043a\u0430 \u0441\u043b\u0430\u0434\u043e\u0441\u0442\u0435\u0439:<\/p>\n<pre><code class=\"java\">@Bean @ConditionalOnTimeAndDayOfWeek public CandyShop candyShop() {    return new CandyShop(); }<\/code><\/pre>\n<h3>OR<\/h3>\n<p>\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u0439, \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u043d\u044b\u0445 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u00ab\u0438\u043b\u0438\u00bb. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u043b\u0430\u0441\u0441, \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u044e\u0449\u0438\u0439 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 AnyNestedCondition:<\/p>\n<pre><code class=\"java\">public class TimeOrDayOfWeekConditions extends AnyNestedCondition {     public TimeOrDayOfWeekConditions() {        super(ConfigurationPhase.REGISTER_BEAN);    }     @Conditional(TimeCondition.class)    static class OnTimeCondition {    }     @ConditionalOnDayOfWeek    static class OnDayOfWeekCondition {    } }<\/code><\/pre>\n<p>\u0414\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0435 \u0448\u0430\u0433\u0438 \u0432\u0430\u043c \u0443\u0436\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u044b: \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e, \u0430 \u043f\u043e\u0442\u043e\u043c \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0435\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 \u0444\u0430\u0431\u0440\u0438\u043a\u0438 \u043a \u043b\u044e\u0431\u043e\u043c\u0443 \u0431\u0438\u043d\u0443.<\/p>\n<p>\u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0442\u044c \u2014 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u0439 &#171;AND&#187; \u0432 \u043e\u0434\u043d\u043e &#171;OR&#187;. AllNestedConditions \u0438 AnyNestedCondition \u043c\u043e\u0433\u0443\u0442 \u043f\u0440\u0438\u043d\u044f\u0442\u044c \u043b\u044e\u0431\u044b\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u2014 \u043a\u0430\u043a \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435, \u0442\u0430\u043a \u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0435 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e. \u0412\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u043d\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u0432\u043b\u0438\u044f\u043d\u0438\u044f \u043d\u0435 \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u2014 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043a\u0430\u043a \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u0439 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438, \u0442\u0430\u043a \u0438 @Conditional \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c \u2014 \u043a\u043b\u0430\u0441\u0441\u043e\u043c, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 Condition.<\/p>\n<h3>ConfigurationPhase<\/h3>\n<p>\u041e\u0431\u0430 \u043a\u043b\u0430\u0441\u0441\u0430, \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u044e\u0449\u0438\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442 \u0432 \u0441\u0432\u043e\u0435\u043c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 ConfigurationPhase, enum. \u041e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043e\u0434\u043d\u043e \u0438\u0437 \u0434\u0432\u0443\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439: <\/p>\n<ul>\n<li>\n<p>PARSE_CONFIGURATION \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0430\u0434 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438, \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044b\u043c\u0438 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0435\u0439 @Configuration<\/p>\n<\/li>\n<li>\n<p>REGISTER_BEAN \u2014 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440, \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0449\u0438\u0439\u0441\u044f \u043f\u0440\u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e (\u043d\u0435 @Configuration) bean-\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430<\/p>\n<\/li>\n<\/ul>\n<p>\u0412\u043e\u0442 \u043c\u044b \u0438 \u043e\u0441\u0432\u043e\u0438\u043b\u0438 \u043d\u0430\u0432\u044b\u043a\u0438 \u0442\u043e\u0447\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0447\u0435\u0440\u0435\u0437 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0431\u0438\u043d\u043e\u0432. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0445 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0433\u0438\u0431\u043a\u0438\u0435 \u0438 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043a \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u041a \u0442\u043e\u043c\u0443 \u0436\u0435 \u044d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043b\u0438\u0448\u043d\u0438\u0445 \u0431\u0438\u043d\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0415\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0438\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441\u0432\u043e\u0438\u043c \u043e\u043f\u044b\u0442\u043e\u043c, \u0434\u043e\u0431\u0440\u043e \u043f\u043e\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438. \u0412\u0441\u0435 \u043f\u043e\u0447\u0438\u0442\u0430\u044e \u0438 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u0435\u0440\u043d\u0443\u0441\u044c \u0441 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0439 \u0441\u0432\u044f\u0437\u044c\u044e!<\/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\/825014\/\"> https:\/\/habr.com\/ru\/articles\/825014\/<\/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<h3>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440! \u041d\u0430 \u0441\u0432\u044f\u0437\u0438 \u0441\u043d\u043e\u0432\u0430 \u0421\u0435\u0440\u0433\u0435\u0439 \u0421\u043e\u043b\u043e\u0432\u044b\u0445, Java-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u041c\u0422\u0421 Digital. <\/h3>\n<p>\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044e \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043e Spring Boot Starter. \u0412 <a href=\"https:\/\/habr.com\/ru\/companies\/ru_mts\/articles\/811693\/\">\u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0447\u0430\u0441\u0442\u0438<\/a> \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0442\u0430\u0440\u0442\u0435\u0440 \u043a\u0430\u043a \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0443\u044e \u043a \u0434\u0440\u0443\u0433\u043e\u043c\u0443 Spring-Boot-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f \u0441 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438, \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c\u0438 \u0438 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u043c\u0438 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f\u043c\u0438. <\/p>\n<figure class=\"full-width\"><\/figure>\n<h2>\u0417\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438<\/h2>\n<p>\u0421\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u043d\u0430\u043c\u0438 \u043a\u0430\u0440\u043a\u0430\u0441 Spring-Boot-\u0441\u0442\u0430\u0440\u0442\u0435\u0440\u0430 \u0431\u044b\u043b \u043d\u0435\u043f\u043b\u043e\u0445 \u0434\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043e\u0431\u0449\u0438\u0445 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u0432 \u0438 \u0437\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u0430 \u0441 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0438\u0430\u043b\u044c\u043d\u044b\u043c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e\u043c. \u041d\u043e \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043f\u0435\u0440\u0435\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0435\u0433\u043e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443. \u041c\u044b \u0440\u0435\u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0443\u0435\u043c \u0444\u0430\u0431\u0440\u0438\u043a\u0438: \u0442\u0435\u043f\u0435\u0440\u044c \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0442\u044c\u0441\u044f \u043d\u0435 \u043f\u043e \u0442\u0438\u043f\u0430\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 (\u0436\u0438\u0432\u043e\u0442\u043d\u044b\u0435 \u0438 \u043c\u0435\u0441\u0442\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044f), \u0430 \u043f\u043e \u043f\u0440\u043e\u0444\u0438\u043b\u044e \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0431\u0438\u0442\u0430\u0442\u0435\u043b\u044f. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u043d\u043a\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443.<\/p>\n<p>\u041a\u0430\u0436\u0434\u0443\u044e \u0444\u0430\u0431\u0440\u0438\u043a\u0443 \u043d\u0430\u0437\u043e\u0432\u0435\u043c \u043f\u043e \u0438\u043c\u0435\u043d\u0438 \u043e\u0431\u0438\u0442\u0430\u0442\u0435\u043b\u044f \u0438 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0435\u043c \u0442\u0443\u0434\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0438\u0442\u043e\u043c\u0446\u0430 \u0438 \u0432\u043e\u043b\u044c\u0435\u0440\u044b \u0434\u043b\u044f \u043d\u0435\u0433\u043e:<\/p>\n<pre><code class=\"java\">@AutoConfiguration(\"napoleonFactory\") public class NapoleonFactory {     @Bean    public Napoleon napoleon() {        return new Napoleon();    }     @Bean    public Lawn lawn(Napoleon napoleon) {        return new Lawn(napoleon);    } }<\/code><\/pre>\n<p>\u041e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0435\u0441\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u0435: \u041d\u0430\u043f\u043e\u043b\u0435\u043e\u043d \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0447\u0442\u043e-\u0442\u043e \u0436\u0443\u0435\u0442, \u0438 \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043c\u043e\u0433 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u043a\u043e\u0441\u043c\u043e\u0437\u043e\u043e\u043f\u0430\u0440\u043a\u0435, \u043d\u0430 \u0435\u0433\u043e \u0442\u0435\u0440\u0440\u0438\u0442\u043e\u0440\u0438\u0438 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043e\u0433\u043e\u0440\u043e\u0434 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u043e\u0432\u043e\u0449\u0430\u043c\u0438. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043b\u0430\u0441\u0441 <strong>Garden:<\/strong><\/p>\n<pre><code class=\"java\">@RequiredArgsConstructor public class Lawn {     private final Napoleon napoleon;     public static class Garden { \/\/code    } }<\/code><\/pre>\n<p>\u0418 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0435\u0433\u043e \u0432 \u0444\u0430\u0431\u0440\u0438\u043a\u0443:<\/p>\n<pre><code class=\"java\">@AutoConfiguration(\"napoleonFactory\") public class NapoleonFactory {     @Bean    public Napoleon napoleon() {        System.out.println(\"Napoleon created\");        return new Napoleon();    }     @Bean    public Lawn.Garden garden() {        System.out.println(\"Garden created\");        return new Lawn.Garden();    }     @Bean    public Lawn lawn(Napoleon napoleon) {        System.out.println(\"Lawn created\");        return new Lawn(napoleon);    } }<\/code><\/pre>\n<p>\u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0442\u0435\u0441\u0442 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438:<\/p>\n<pre><code class=\"java\">@SpringBootTest(classes = NapoleonFactory.class) class NapoleonFactoryTest {     @Autowired    private ApplicationContext context;     @ParameterizedTest    @MethodSource(\"beanNames\")    void applicationContextContainsBean(String beanName) {        Assertions.assertTrue(context.containsBean(beanName));    }     private static Stream&lt;String> beanNames() {        return Stream.of(                \"napoleonFactory\",                \"napoleon\",                \"garden\",                \"lawn\"        );    } }<\/code><\/pre>\n<p>\u0412\u0441\u0435 \u0431\u0438\u043d\u044b \u0441\u043e\u0437\u0434\u0430\u043d\u044b, \u043d\u043e \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u2014 \u0432\u044b\u0432\u043e\u0434 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0438\u0445 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f:<\/p>\n<pre><code class=\"java\">Napoleon created Garden created Lawn created<\/code><\/pre>\n<p>\u041a\u0430\u043a \u043f\u0435\u0440\u0435\u0434 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435\u043c \u041d\u0430\u043f\u043e\u043b\u0435\u043e\u043d\u0430 \u043d\u0430\u043c \u0431\u044b\u0442\u044c \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u043c\u0438, \u0447\u0442\u043e \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u043e\u0433\u043e\u0440\u043e\u0434? \u0422\u0443\u0442 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u043e\u0447\u044c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f <strong>@DependsOn.<\/strong> \u041a\u0430\u043a \u0433\u043b\u0430\u0441\u0438\u0442 <strong>javadoc<\/strong> \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 <strong>@DependsOn<\/strong>, \u043e\u043d\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u043c\u0435\u043d \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432, \u043e\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043d\u0430\u0448 <strong>bean<\/strong>. \u0410 \u0435\u0449\u0435 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442, \u0447\u0442\u043e:<\/p>\n<ul>\n<li>\n<p>\u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u044b \u0434\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 <strong>bean&#8217;\u0430<\/strong><\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430<strong> bean&#8217;\u0430<\/strong>, \u0430 \u043f\u043e\u0442\u043e\u043c \u0435\u0433\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0443\u043a\u0430\u0436\u0435\u043c, \u0447\u0442\u043e \u043e\u0431\u044a\u0435\u043a\u0442 <strong>&#171;napoleon&#187;<\/strong> \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 <strong>&#171;garden&#187;<\/strong>, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442, \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d \u043f\u043e\u0441\u043b\u0435 \u043d\u0435\u0433\u043e:<\/p>\n<pre><code class=\"java\">@Bean @DependsOn(\"garden\") public Napoleon napoleon() {    System.out.println(\"Napoleon created\");    return new Napoleon(); }<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0442\u0435\u0441\u0442 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0432\u044b\u0432\u043e\u0434 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c:<\/p>\n<pre><code class=\"java\">Garden created Napoleon created Lawn created<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u0441\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e. \u0423\u0441\u043b\u043e\u0432\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442, \u0447\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u0435 \u0431\u0438\u043d\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0443\u0442\u0441\u044f. \u0418\u043d\u0430\u0447\u0435, \u0435\u0441\u043b\u0438 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 &#171;<strong>garden<\/strong>&#171;, \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0443\u043f\u0430\u0434\u0435\u0442 \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439 NoSuchBeanDefinitionException. <\/p>\n<h2>\u0423\u0441\u043b\u043e\u0432\u0438\u044f<\/h2>\n<h3>\u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438<\/h3>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 <a href=\"https:\/\/docs.spring.io\/spring-boot\/docs\/current\/reference\/htmlsingle\/#features.developing-auto-configuration.condition-annotations\"><strong>@ConditionOn<\/strong><\/a> \u043e\u0442 <strong>@DependsOn<\/strong> \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043d\u0435\u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u043d\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442 \u043a \u043e\u0448\u0438\u0431\u043a\u0435 \u0441\u0442\u0430\u0440\u0442\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d \u0431\u0438\u043d \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430. \u0422\u0430\u043a\u0436\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0431\u043e\u043b\u0435\u0435 \u0433\u0438\u0431\u043a\u0438\u0435 \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u0435\u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440.<\/p>\n<h3>@ConditionalOnProperty<\/h3>\n<p>\u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043f\u0440\u0435\u0434\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438. \u0421 \u0438\u0445 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0438\u043b\u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0432 \u0444\u0430\u0439\u043b\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438. \u042d\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430-\u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0438 \u043d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439, \u0435\u0441\u043b\u0438 \u0432 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0438\u043b\u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u0441\u0435\u0440\u0432\u0438\u0441. <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0412\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a \u043d\u0430\u0448\u0435\u043c\u0443 \u043f\u0440\u0438\u043c\u0435\u0440\u0443. \u0412\u044b\u044f\u0441\u043d\u0438\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0434\u0435\u0442\u0441\u043a\u0438\u0445 \u044d\u043a\u0441\u043a\u0443\u0440\u0441\u0438\u0439 \u0432 \u0437\u043e\u043e\u043f\u0430\u0440\u043a \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0435\u0442\u0438 \u043f\u0443\u0433\u0430\u044e\u0442\u0441\u044f \u0442\u0438\u0433\u0440\u043e\u043a\u0440\u044b\u0441\u0430 \u2014 \u0443\u0436 \u0431\u043e\u043b\u044c\u043d\u043e \u0441\u0432\u0438\u0440\u0435\u043f\u044b\u043c \u043e\u043d \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442. \u0422\u0430\u043a \u0447\u0442\u043e \u0431\u044b\u043b\u043e \u0440\u0435\u0448\u0435\u043d\u043e \u043d\u0435 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u0434\u043d\u0438 \u044d\u043a\u0441\u043a\u0443\u0440\u0441\u0438\u0439 \u043c\u0430\u043b\u044b\u0448\u0435\u0439. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043d\u0430\u0448\u0435\u0433\u043e \u0437\u043e\u043e\u043f\u0430\u0440\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0438 \u0432\u044b\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e \u0436\u0438\u0432\u043e\u0442\u043d\u043e\u0433\u043e. \u0412 \u0444\u0430\u0439\u043b <strong>application.properties<\/strong> \u0432\u043d\u0435\u0441\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440:<\/p>\n<pre><code class=\"java\">app.tigrokris.create=false<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0431\u0440\u0438\u043a\u0443 \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0442\u0430\u043c \u0434\u0430\u043d\u043d\u0443\u044e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e:<\/p>\n<pre><code class=\"java\">@Bean @ConditionalOnProperty(        value = \"app.tigrokris.create\",        havingValue = \"true\",        matchIfMissing = false ) public Tigrokris tigrokris() {    return new Tigrokris(); }<\/code><\/pre>\n<p>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <strong>value = &#171;app.tigrokris.create&#187;<\/strong> \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430. <strong>havingValue = &#171;true&#187;<\/strong> \u2014 \u044d\u0442\u043e \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u044f. <strong>matchIfMissing = false<\/strong> \u2014 \u044d\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430.<\/p>\n<h3>@ConditionalOnBean \u0438 @ConditionalOnMissingBean<\/h3>\n<p>\u0410\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f <strong>@ConditionalOnBean<\/strong> \u0434\u0438\u043a\u0442\u0443\u0435\u0442 \u0443\u0441\u043b\u043e\u0432\u0438\u044f, \u0447\u0442\u043e \u0431\u0438\u043d \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d, \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0435\u0441\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0438\u043b\u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f. \u041f\u0440\u0438\u043c\u0435\u043d\u044f\u044f <strong>@ConditionalOnMissingBean,<\/strong> \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435: \u0431\u0438\u043d \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430. \u042d\u0442\u0438 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u0435\u0437\u043d\u044b \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0439 \u0434\u043b\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0441\u0440\u0435\u0434 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u0430 \u0435\u0449\u0435 \u0434\u043b\u044f \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\u0438.<\/p>\n<p>\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0431\u044b\u043b\u0430 \u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f, \u0447\u0442\u043e \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445 \u0431\u0438\u043d \u043a\u043b\u0430\u0441\u0441\u0430 <strong>Tigrokris<\/strong> \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d. \u041d\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0443\u043f\u0430\u0441\u0442\u044c \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439 \u2014 \u044d\u0442\u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0432\u043e\u043b\u044c\u0435\u0440\u0430. \u041c\u043e\u0436\u043d\u043e, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0438 \u0442\u0443\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c <strong>@ConditionalOnProperty <\/strong>\u0441 \u0442\u0435\u043c \u0436\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435\u043c, \u043d\u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0431\u0443\u0434\u0435\u0442 \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u0431\u0438\u043d\u0430 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435. \u0422\u043e \u0435\u0441\u0442\u044c \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u0431\u0438\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0438\u043b\u0438 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0442\u044c\u0441\u044f \u043a\u043b\u0435\u0442\u043a\u0430 \u0434\u043b\u044f \u0442\u0438\u0433\u0440\u043e\u043a\u0440\u044b\u0441\u0430. \u0412\u043e\u0442 \u0442\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432\u0441\u044f \u0444\u0430\u0431\u0440\u0438\u043a\u0430 \u0446\u0435\u043b\u0438\u043a\u043e\u043c:<\/p>\n<pre><code class=\"java\">@AutoConfiguration(\"tigrokrisFactory\") public class TigrokrisFactory {     @Bean    @ConditionalOnProperty(            value = \"app.tigrokris.create\",            havingValue = \"true\",            matchIfMissing = false    )    public Tigrokris tigrokris() {        return new Tigrokris();    }     @Bean    @ConditionalOnBean(name = \"tigrokris\")    public ClosedEnclosure closedEnclosure(Tigrokris tigrokris) {        return new ClosedEnclosure(tigrokris);    } }<\/code><\/pre>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0442\u0435\u0441\u0442:<\/p>\n<pre><code class=\"java\">@SpringBootTest(classes = TigrokrisFactory.class) class TigrokrisFactoryTest {     @Autowired    private ApplicationContext context;     @ParameterizedTest    @MethodSource(\"beanNames\")    void applicationContextContainsBean(String beanName, boolean expected) {        Assertions.assertEquals(expected, context.containsBean(beanName));    }     private static Stream&lt;Arguments> beanNames() {        return Stream.of(                Arguments.of(\"tigrokrisFactory\", true),                Arguments.of(\"tigrokris\", false),                Arguments.of(\"closedEnclosure\", false)        );    } }<\/code><\/pre>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0440\u0430\u0437\u0443 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0438\u043c \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043d\u0430 \u0432\u0441\u0435 \u0432\u043e\u043b\u044c\u0435\u0440\u044b.<\/p>\n<h3>@ConditionalOnResource<\/h3>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u0430. \u042d\u0442\u043e\u0439 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043b\u043e\u0433\u0433\u0435\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u2014 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a\u043e\u0439 \u0444\u0430\u0439\u043b \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d \u0432 classpath (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, logback.xml). <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u044d\u0442\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043a \u0428\u0443\u0448\u0435. \u0428\u0443\u0448\u0430 \u2014 \u043b\u0438\u0447\u043d\u043e\u0441\u0442\u044c \u0442\u0432\u043e\u0440\u0447\u0435\u0441\u043a\u0430\u044f. \u041b\u0443\u043d\u043d\u044b\u043c\u0438 \u043d\u043e\u0447\u0430\u043c\u0438 \u043e\u043d \u043b\u044e\u0431\u0438\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0442\u0438\u0445\u0438. \u0418 \u0440\u044f\u0434\u043e\u043c \u0432\u0441\u0435\u0433\u0434\u0430 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0431\u043b\u043e\u043a\u043d\u043e\u0442, \u043a\u0443\u0434\u0430 \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u043e, \u0447\u0442\u043e \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u0430\u043b\u0430 \u0435\u043c\u0443 \u043c\u0443\u0437\u0430. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0439\u043b <strong>notebook.txt <\/strong>\u0438 \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u043c \u0435\u0433\u043e \u0432 \u043f\u0430\u043f\u043a\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432. \u0424\u0430\u0431\u0440\u0438\u043a\u0430 \u043f\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0442\u0438\u043f\u0430 <strong>Shusha<\/strong> \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"java\">@AutoConfiguration(\"shushaFactory\") public class ShushaFactory {     @Bean    @ConditionalOnResource(resources = \"classpath:notebook.txt\")    public Shusha shusha() {        return new Shusha();    }     @Bean    @ConditionalOnBean(name = \"shusha\")    public Park park(Shusha shusha) {        return new Park(shusha);    } }<\/code><\/pre>\n<p>\u041f\u043e\u0442\u043e\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0442\u0435\u0441\u0442:<\/p>\n<pre><code class=\"java\">@SpringBootTest(classes = ShushaFactory.class) class ShushaFactoryTest {     @Autowired    private ApplicationContext context;     @ParameterizedTest    @MethodSource(\"beanNames\")    void applicationContextContainsBean(String beanName) {        Assertions.assertTrue(context.containsBean(beanName));    }     private static Stream&lt;String> beanNames() {        return Stream.of(                \"shushaFactory\",                \"shusha\",                \"park\"        );    } }<\/code><\/pre>\n<h3>@ConditionalOnExpression<\/h3>\n<p>\u042d\u0442\u0430 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043a\u0430\u043a \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f SpEL-\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u044e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u044f \u043e\u0431\u044a\u0435\u043a\u0442-\u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043c\u0435\u0441\u0442\u0438\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439, \u043d\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0439 \u0432 \u044d\u0442\u043e\u043c \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0438 \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0438\u0441 \u0441 \u043d\u0443\u0436\u043d\u044b\u043c\u0438 \u043d\u0430\u043c \u0434\u0430\u043d\u043d\u044b\u043c\u0438: &#171;${app.web.stub.enabled} and ${app.web.mock.data}&#187;.<\/p>\n<p>\u0421\u0438\u043d\u0438\u0439, \u043a\u0430\u043a \u0438 \u0432\u0441\u0435 \u0440\u0435\u043f\u0442\u0438\u043b\u0438\u0438, \u043e\u0447\u0435\u043d\u044c \u043b\u044e\u0431\u0438\u0442 \u0433\u0440\u0435\u0442\u044c\u0441\u044f \u043d\u0430 \u043f\u0435\u0441\u043e\u0447\u043a\u0435 \u0432 \u044f\u0441\u043d\u0443\u044e \u0442\u0435\u043f\u043b\u0443\u044e \u043f\u043e\u0433\u043e\u0434\u0443. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0434\u0432\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"java\">app.sun.is-shining=true app.weather=clear<\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0443 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0431\u0443\u043b\u0435\u0432\u043e, \u0430 \u0443 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u2014 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u043e\u0435. \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u044d\u0442\u0438\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Spring Expression Language:<\/p>\n<pre><code class=\"java\">@AutoConfiguration(\"siniiFactory\") public class SiniiFactory {  @Bean @ConditionalOnExpression(\"${app.sun.is-shining} and '${app.weather}'.equals('clear')\") public Sinii sinii() {    return new Sinii(); }     @Bean    @ConditionalOnBean(name = \"sinii\")    public Swamp swamp(Sinii sinii) {        return new Swamp(sinii);    } }<\/code><\/pre>\n<p>\u041c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u0432\u0441\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f, \u0438 \u0421\u0438\u043d\u0438\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0434\u043e\u0432\u043e\u043b\u0435\u043d. \u0414\u0430\u043b\u044c\u0448\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430:<\/p>\n<pre><code class=\"java\">@SpringBootTest(classes = SiniiFactory.class) class SiniiFactoryTest {     @Autowired    private ApplicationContext context;     @ParameterizedTest    @MethodSource(\"beanNames\")    void<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\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-380143","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/380143","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=380143"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/380143\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=380143"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=380143"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=380143"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}