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

前端 未结 27 1458
一整个雨季
一整个雨季 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:32

    I had multiple application classes in one Spring Boot project which had the web started included and wanted to avoid it configuring a web environment for one of them so I manually configured it as below:

    @SpringBootApplication
    public class Application
    {
        public static void main(String[] args)
        {
            new SpringApplicationBuilder(Application.class)
                .web(false)
                .run(args);
        }
    }
    

    UPDATE for Spring Boot 2 and above:

    @SpringBootApplication
    public class Application
    {
        public static void main(String[] args)
        {
            new SpringApplicationBuilder(Application.class)
                .web(WebApplicationType.NONE)
                .run(args);
        }
    }
    

提交回复
热议问题