[ROZWIĄZANY] – Spring Boot: Error starting ApplicationContext. To display the auto-configuration report re-run your application with ‘debug’ enabled.

[ROZWIĄZANY] – Spring Boot: Error starting ApplicationContext. To display the auto-configuration report re-run your application with ‘debug’ enabled.

Tytułowy komunikat oznacza mniej więcej tyle, że coś poszło nie tak jak trzeba podczas startu aplikacji SpringBoot. Bardzo często przyczynę można zdiagnozować w kilka chwil analizując dalszą część loga. W poniższym wpisie omówimy kilka najczęstszych przyczyn błędów podczas startowania kontekstu Spring.

1. Potencjalne przyczyny problemu

Dalszą cześć artykułu podzieliłem na dwie główne grupy problemów, które mogą powodować problemy z wystartowaniem aplikacji dając w efekcie tytułowy problem. Pierwszą stanowią problemu z błędami w kodzie lub brakiem odpowiednich bibliotek. Do drugiej grupy problemów zaliczamy te związane z autokonfiguracją aplikacji opartej Spring, czyli kwestie środowiska w jakim dana aplikacja została uruchomiona. Jeśli wiesz już na czym polega różnica, to od razu możesz przejść do części Raport Autokonfiguracji w Spring Boot.

1.1. Błędy wynikające wprost z kodu aplikacji

Na początek rzućmy okiem na strukturę typowego loga aplikacji, która z jakiegoś powodu nie może wystartować. Zwróć proszę uwagę, że w liniach 14-15 można znaleźć tytułowy komunikat:

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.

Application startup failed

Pełny log zamieszczam poniżej. Kliknij tu aby przejść do jego analizy.

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.8.RELEASE)

2019-09-15 04:17:11.225  INFO 18004 --- [           main] com.bettercoding.lab.MyApp               : Starting MyApp on DESKTOP with PID 18004 (D:\Workspace\date1927\out\production\classes started by LCiesla in D:\Workspace\date1927)
2019-09-15 04:17:11.229  INFO 18004 --- [           main] com.bettercoding.lab.MyApp               : No active profile set, falling back to default profiles: default
2019-09-15 04:17:11.683  WARN 18004 --- [           main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'myApp': Unsatisfied dependency expressed through field 'myCustomBean'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myCustomBean' defined in file [D:\Workspace\date1927\out\production\classes\com\bettercoding\lab\MyCustomBean.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.bettercoding.lab.MyCustomBean]: Constructor threw exception; nested exception is java.lang.RuntimeException: Enforced Exception
2019-09-15 04:17:11.692  INFO 18004 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-09-15 04:17:11.697 ERROR 18004 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'myApp': Unsatisfied dependency expressed through field 'myCustomBean'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myCustomBean' defined in file [D:\Workspace\date1927\out\production\classes\com\bettercoding\lab\MyCustomBean.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.bettercoding.lab.MyCustomBean]: Constructor threw exception; nested exception is java.lang.RuntimeException: Enforced Exception
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:596) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:374) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1411) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:592) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:845) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744) ~[spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391) ~[spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) ~[spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) ~[spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1204) ~[spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
	at com.bettercoding.lab.MyApp.main(MyApp.java:17) ~[classes/:na]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myCustomBean' defined in file [D:\Workspace\date1927\out\production\classes\com\bettercoding\lab\MyCustomBean.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.bettercoding.lab.MyCustomBean]: Constructor threw exception; nested exception is java.lang.RuntimeException: Enforced Exception
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1303) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1197) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:277) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1251) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1171) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:593) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	... 18 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.bettercoding.lab.MyCustomBean]: Constructor threw exception; nested exception is java.lang.RuntimeException: Enforced Exception
	at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:184) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1295) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	... 29 common frames omitted
Caused by: java.lang.RuntimeException: Enforced Exception
	at com.bettercoding.lab.MyCustomBean.<init>(MyCustomBean.java:8) ~[classes/:na]
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:na]
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:na]
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:na]
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500) ~[na:na]
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481) ~[na:na]
	at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:172) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	... 31 common frames omitted


Process finished with exit code 1

1.1.2. Analiza

Wykonajmy zatem próbę analizy powyższego loga czytając go od początku. Na wstępie widzimy baner Spring, następnie mijamy informację o tym, w jakich warunkach aplikacja została wystartowania, po to aby już w 11 linii uzyskać w zasadzie odpowiedź na pytanie co się właściwie stało. A mianowicie linia ta mówi, że podczas startu aplikacji, nie znaleziono jednego z beanów (o nazwie myCustomBean), ponieważ podczas jego tworzenia (w konstruktorze) wystąpił wyjątek o treści “Enforced Exception”.

Na tym moglibyśmy poprzestać. Czasem jednak istnieją bardziej skomplikowane problemy ze startem aplikacji. W takim przypadku jeśli czytanie loga od góry do dołu nie przyniesie Ci odpowiedzi, to warto przeczytać go drugi raz. Tym razem od końca, ponieważ zwykle bezpośrednia przyczyna znajduje się właśnie tam. Zobaczmy to na naszym przykładzie.

Zaczynając od linii 54, która mówi “Podczas tworzenia nowego beana”, następnie przechodząc przez linię 37, która mówi “Wystąpił wyjątek podczas tworzenia beana” z powodu wystąpienia RuntimeException o treści “Enforced Exception”.

1.2. Raport Autokonfiguracji w Spring Boot – Auto-Configuration Report

Czasem jednak przyczyna problemu ze startem aplikacji nie lezy bezpośrednio w kodzie aplikacji, a np. w warunkach środowiska uruchomieniowego. Zobacz chociażby na poniższą aplikację. Zanim jednak przejdziemy do jej uruchomienia, to zwróć proszę uwagę a linie 32-37. Zdefinowałem tam komponent MyCustomBean oznaczony adnotacją @ConditionalOnProperty, który zostanie dodany do kontekstu Spring tylko w przypadku, gdy będzie zdefiniowana właściwość my-property.

package com.bettercoding.lab;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.stereotype.Component;

@SpringBootApplication
public class MyApp {

    @Autowired
    private MyCustomBean myCustomBean;

    public static void main(String[] args) {
        SpringApplication.run(MyApp.class, args);
    }
    @Bean
    public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
        return new CommandLineRunner() {
            @Override
            public void run(String... args) throws Exception {
                System.out.println("Hello World");
            }
        };
    }

    @Component
    @ConditionalOnProperty("my-property")
    public static class MyCustomBean {
        public MyCustomBean() {
        }
    }
}

Podczas uruchamiania aplikacji otrzymujemy komunikat mówiący, że w konfiguracji brakuje beana – linia 31.

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.8.RELEASE)

2019-09-16 07:18:50.500  INFO 10496 --- [           main] com.bettercoding.lab.MyApp               : Starting MyApp on DESKTOP-97OFJ5Q with PID 10496 (D:\Workspace\date1927\out\production\classes started by LCiesla in D:\Workspace\date1927)
2019-09-16 07:18:50.503  INFO 10496 --- [           main] com.bettercoding.lab.MyApp               : No active profile set, falling back to default profiles: default
2019-09-16 07:18:50.941  WARN 10496 --- [           main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'myApp': Unsatisfied dependency expressed through field 'myCustomBean'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.bettercoding.lab.MyApp$MyCustomBean' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
2019-09-16 07:18:50.948  INFO 10496 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-09-16 07:18:51.111 ERROR 10496 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Field myCustomBean in com.bettercoding.lab.MyApp required a bean of type 'com.bettercoding.lab.MyApp$MyCustomBean' that could not be found.

The injection point has the following annotations:
	- @org.springframework.beans.factory.annotation.Autowired(required=true)


Action:

Consider defining a bean of type 'com.bettercoding.lab.MyApp$MyCustomBean' in your configuration.


Process finished with exit code 1

Jak widać w tym przypadku nie ma żadnej dodatkowej informacji, o powodzie dla którego owy bean nie został dodany do kontekstu Spring, a przecież jest on,wydawało by się, zdefiniowany poprawnie. W tym momencie z pomocą przychodzi nam raport autokonfiguracji. Aby go włączyć dodaj parametr -Ddebug=true do linii uruchomienia aplikacji.

Po ponownym uruchomieniu aplikacji w logu dostaniemy raport z którego analizy można wywnioskować, co jest przyczyną problemu z naszą aplikacją. Wystarczy w tym celu przeszukać raport pod kątem wystąpienia beana MyCustomBean. Nasz odpowiedź znajduje się w linii 46 poniższego loga, czyli nie zarejestrowano beana ponieważ nie znaleziono właściwości o nazwie my-property. Aby ją dodać należy np. do linii poleceń dodać -Dmy-property.

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.8.RELEASE)

2019-09-16 07:29:51.365  INFO 11712 --- [           main] com.bettercoding.lab.MyApp               : Starting MyApp on DESKTOP-97OFJ5Q with PID 11712 (D:\Workspace\date1927\out\production\classes started by LCiesla in D:\Workspace\date1927)
2019-09-16 07:29:51.366  INFO 11712 --- [           main] com.bettercoding.lab.MyApp               : No active profile set, falling back to default profiles: default
2019-09-16 07:29:51.366 DEBUG 11712 --- [           main] o.s.boot.SpringApplication               : Loading source class com.bettercoding.lab.MyApp
2019-09-16 07:29:51.886  WARN 11712 --- [           main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'myApp': Unsatisfied dependency expressed through field 'myCustomBean'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.bettercoding.lab.MyApp$MyCustomBean' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
2019-09-16 07:29:51.890 DEBUG 11712 --- [           main] .c.l.ClasspathLoggingApplicationListener : Application failed to start with classpath: unknown
2019-09-16 07:29:51.926 DEBUG 11712 --- [           main] ConditionEvaluationReportLoggingListener : 


============================
CONDITIONS EVALUATION REPORT
============================


Positive matches:
-----------------

   GenericCacheConfiguration matched:
      - Cache org.springframework.boot.autoconfigure.cache.GenericCacheConfiguration automatic cache type (CacheCondition)

   JmxAutoConfiguration matched:
      - @ConditionalOnClass found required class 'org.springframework.jmx.export.MBeanExporter' (OnClassCondition)
      - @ConditionalOnProperty (spring.jmx.enabled=true) matched (OnPropertyCondition)

   ...


Negative matches:
-----------------

   ActiveMQAutoConfiguration:
      Did not match:
         - @ConditionalOnClass did not find required class 'javax.jms.ConnectionFactory' (OnClassCondition)

  ...

   MyApp.MyCustomBean:
      Did not match:
         - @ConditionalOnProperty (my-property) did not find property 'my-property' (OnPropertyCondition)

   


Exclusions:
-----------

    None


Unconditional classes:
----------------------

    org.springframework.boot.autoconfigure.context.ConfigurationPropertiesAutoConfiguration

    org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration

    org.springframework.boot.autoconfigure.info.ProjectInfoAutoConfiguration



2019-09-16 07:29:52.148 DEBUG 11712 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : Application failed to start due to an exception

org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.bettercoding.lab.MyApp$MyCustomBean' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1658) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1217) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1171) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:593) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:374) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1411) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:592) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:845) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744) ~[spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391) ~[spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) ~[spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) ~[spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1204) ~[spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
	at com.bettercoding.lab.MyApp.main(MyApp.java:20) ~[classes/:na]

2019-09-16 07:29:52.149 ERROR 11712 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Field myCustomBean in com.bettercoding.lab.MyApp required a bean of type 'com.bettercoding.lab.MyApp$MyCustomBean' that could not be found.

The injection point has the following annotations:
	- @org.springframework.beans.factory.annotation.Autowired(required=true)


Action:

Consider defining a bean of type 'com.bettercoding.lab.MyApp$MyCustomBean' in your configuration.


Process finished with exit code 1
Na zakończenie mam jeszcze jedną prośbę.

Jeśli pomogłem Ci rozwiązać problem, to udostępnij proszę ten post. Dzięki temu będę miał okazję trafić do szerszej grupy odbiorców. Dziękuję

Leave a Reply

avatar
  Subscribe  
Notify of
Close Menu