Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean

今天想練習下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>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章