Spring Boot: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean

前端 未结 27 1391
一整个雨季
一整个雨季 2020-11-28 03:55

I am totally new to Spring and started to do the official guides from this site: https://spring.io/guides

I\'d like to do this guide: https://spring.io/guides/gs/sch

27条回答
  •  失恋的感觉
    2020-11-28 04:42

    A SpringApplication will attempt to create the right type of ApplicationContext on your behalf. By default, an AnnotationConfigApplicationContext or AnnotationConfigEmbeddedWebApplicationContext will be used, depending on whether you are developing a web application or not.

    The algorithm used to determine a ‘web environment’ is fairly simplistic (based on the presence of a few classes). You can use setWebEnvironment(boolean webEnvironment) if you need to override the default.

    It is also possible to take complete control of the ApplicationContext type that will be used by calling setApplicationContextClass(…​).

    [Tip] It is often desirable to call setWebEnvironment(false) when using SpringApplication within a JUnit test.

提交回复
热议问题