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

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

    A scan of the @SpringBootApplication show that it includes the following annotations:

    @Configuration
    @ComponentScan
    @EnableAutoConfiguration
    

    So you could do this too:

    @SpringBootApplication
    public class Application {
        public static void main(String[] args) {
           SpringApplication.run(ScheduledTasks.class, args);
        }
    }
    
    0 讨论(0)
  • 2020-11-28 04:29

    Probably you missing @SpringBootApplication in your spring boot starter class.

    @SpringBootApplication
    public class LoginSecurityAppApplication {
    
        public static void main(String[] args) {
            SpringApplication.run(LoginSecurityAppApplication.class, args);
        }
    
    }
    
    0 讨论(0)
  • 2020-11-28 04:31

    I've had similar problems when the main method is on a different class than that passed to SpringApplcation.run()

    So the solution would be to use the line you've commented out:

    public class Application {
        public static void main(String[] args) {
            SpringApplication.run(Application.class, args);
        }
    }
    
    0 讨论(0)
  • 2020-11-28 04:31

    I had a similar issue and the problem was a broken maven repo jar file. In my case, the tomcat-embed-core jar file was broken. So I removed it from the maven repo and refreshed it to download again.

    0 讨论(0)
  • 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);
        }
    }
    
    0 讨论(0)
  • 2020-11-28 04:32

    check your pom.xml is exists

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
        </dependency>
    

    I've had a problem like this;For lack this dependency

    0 讨论(0)
提交回复
热议问题