Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean

来源:互联网 发布:韩国人种相貌 知乎 编辑:程序博客网 时间:2024/06/05 07:08

今天想练习下spring boot,然后报了这个错,找了google无果。

其实是maven配置有问题,我把spring boot的内置容器干掉了,spring boot内置tomcat容器,我pom.xml是这样写的。

<dependency>                    <groupId>org.springframework.boot</groupId>                    <artifactId>spring-boot-starter-web</artifactId>                    <version>${springboot.version}</version>                    <!--不需要打包成一个war包,或者说不用内置的spring容器,-->                    <exclusions>                        <exclusion>                            <groupId>org.springframework.boot</groupId>                            <artifactId>spring-boot-starter-tomcat</artifactId>                        </exclusion>                    </exclusions>                </dependency>

我的pom.xml把tomcat容器干掉了,然后我又没有什么容器能够运行,所以会报错。

我只需要使用其他容器就行,比如说下面的undertow 或者jetty

再加个依赖就能跑了

<!-- starter-undertow -->                <dependency>                    <groupId>org.springframework.boot</groupId>                    <artifactId>spring-boot-starter-undertow</artifactId>                    <version>${springboot.version}</version>                    <exclusions>                        <exclusion>                            <artifactId>jboss-logging</artifactId>                            <groupId>org.jboss.logging</groupId>                        </exclusion>                    </exclusions>                </dependency>
0 0