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

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

    Add

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    
    0 讨论(0)
  • 2020-11-28 04:36

    If you run it successfully using command line gradle bootRun, while packaging it with command line gradle jar to jar file in order to run it with command line java -jar build/libs/demo.jar, unfortunately, it failed with Exception: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean, in this case, you need to use task bootRepackage of gradle plugin spring-boot to generate special runnable jar.

    • setup 1

      $ gradle clean bootRepackage

    • setup 2

      $ java -jar build/libs/demo.jar

    0 讨论(0)
  • 2020-11-28 04:37

    if you experience this exception while using intellij and you are trying to start the application with the run button. Try starting the application from the command line instead. E.g. ensure that you are in the correct directory (directory with your pom file) assuming this is a springboot application run mvn spring-boot:run this did the trick for me.

    Additionally I have also seen this error occur when your spring application depends on another application. In this case I had to start the other application first then run.

    0 讨论(0)
  • 2020-11-28 04:38

    I have stuck with same problem. As I didn't define Main.class and the following annotations in Spring-Boot using Maven:

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

    I am using gradle, met seem issue when I have a commandLineRunner consumes kafka topics and a health check endpoint for receiving incoming hooks. I spent 12 hours to figure out, finally found that I used mybatis-spring-boot-starter with spring-boot-starter-web, and they have some conflicts. Latter I directly introduced mybatis-spring, mybatis and spring-jdbc rather than the mybatis-spring-boot-starter, and the program worked well.

    hope this helps

    0 讨论(0)
  • 2020-11-28 04:39

    I had this Exception in the following situation.

    in my POM was properties:

    <properties>
        <java.version>1.8</java.version>
        <!-- The main class to start by executing java -jar -->
        <start-class>com.scmaer.java.microservice.Application</start-class>
        <cxf.version>3.1.5</cxf.version>
        <olingo.version>2.0.10</olingo.version>
        <spring.boot.version>1.4.7.RELEASE</spring.boot.version>
        <spring.boot.plugin.version>1.5.8.RELEASE</spring.boot.plugin.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <skipTests>false</skipTests>
    </properties>
    

    and the name and path of my application class ("start-class") was wrong.

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