开发者社区> 问答> 正文

springboot启动报错Unable to start EmbeddedWe?400报错

前天还没问题,今天启动突然就报这个错。重新从coding下载代码迟迟未能解决。服务器上却可以正常启动。什么鬼?报错如下:


  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.5.8.RELEASE)

2018-05-21 12:10:01.224  INFO 8456 --- [           main] enroll.root.EnrollApplication            : Starting EnrollApplication on DEEP-1711281215 with PID 8456 (G:\03\enroll_list\target\classes started by Administrator in G:\03\enroll_list)
2018-05-21 12:10:01.227  INFO 8456 --- [           main] enroll.root.EnrollApplication            : No active profile set, falling back to default profiles: default
2018-05-21 12:10:01.549  INFO 8456 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@365c30cc: startup date [Mon May 21 12:10:01 CST 2018]; root of context hierarchy
2018-05-21 12:10:02.752  WARN 8456 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
2018-05-21 12:10:02.759  INFO 8456 --- [           main] utoConfigurationReportLoggingInitializer : 

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2018-05-21 12:10:02.766 ERROR 8456 --- [           main] o.s.boot.SpringApplication               : Application startup failed

org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:137) ~[spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537) ~[spring-context-4.3.12.RELEASE.jar:4.3.12.RELEASE]
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
	at enroll.root.EnrollApplication.main(EnrollApplication.java:16) [classes/:na]
Caused by: org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getEmbeddedServletContainerFactory(EmbeddedWebApplicationContext.java:189) ~[spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:162) ~[spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:134) ~[spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
	... 8 common frames omitted

启动类能加的我都加了,@EnableAutoConfiguration之前没加一样能启动,查询各种网站说加上这个即可。但无效。

package enroll.root;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Configuration;

@Configuration
@MapperScan("enroll.root.mapper")
@EnableAutoConfiguration
@SpringBootApplication

public class EnrollApplication {
	public static void main(String[] args) {
		SpringApplication.run(EnrollApplication.class, args);
	}
}

 

展开
收起
爱吃鱼的程序员 2020-06-07 16:18:52 609 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB
                        <p>缺包!</p> 
    
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <version>XXX</version>
    </dependency>

     

                        <div class='ref'><h4>引用来自“Ryan-瑞恩”的评论</h4><p>缺包!</p> 
    
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <version>XXX</version>
    </dependency>

     

                            我现在只是奇怪,前天还能启动,为什么今天就不行了。什么都没变过
                        
    
                            你确定 tomcat-servlet-api 包含了所需要的 包了。你进去 spring-boot-tomcat 里面应该还有其他的吧
    
                        
    
                        我怀疑是这个'<scope>pprovided</scope>的值,在eclipse往IDEA里迁移的时候,容器的scope需要住改成compile 
                    
    
                            我把移除内嵌tomcat去掉重新加了个spring-boot-tomcat就可以启动了,真的很奇怪,pom.xml这样在测试服可以用,本地就挂,周五还能正常启动。。真的灵异事件了,我这样配置半年了项目都没问题。
                        
    
                        <p>这很明显是错误的   这样配置只能编译不能直接运行  要部署到tomcat中     现在的依赖只有servlet api没有真正的容器    不应该排除tomcat依赖</p>
    
                    
    
                            我把移除内嵌tomcat去掉重新加了个spring-boot-tomcat就可以启动了,真的很奇怪,pom.xml这样在测试服可以用,本地就挂,周五还能正常启动。。真的灵异事件了。谢谢你了
                        
    
                        <div class='ref'><h4>引用来自“wxq1990”的评论</h4><p>这很明显是错误的   这样配置只能编译不能直接运行  要部署到tomcat中     现在的依赖只有servlet api没有真正的容器    不应该排除tomcat依赖</p>
    
    
                        <p>我今天也遇到了,公司电脑能正常跑,别人拉拉我的git运行就出了问题。</p> 
    

    Caused by: org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.

    看你这边的解答,然后去试了一下

    IDEA注释掉之后记得要 点下右下角的 import Changes然后运行才能生效

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

    确实可以了问题解决 完美

                        <div class="ref">
    

    引用来自“陈碧滔”的评论

    我怀疑是这个'<scope>pprovided</scope>的值,在eclipse往IDEA里迁移的时候,容器的scope需要住改成compile
                        <p>本地开发,注释掉<exclusions><br>                 <exclusion><br>                     <groupId>org.springframework.boot</groupId><br>                     <artifactId>spring-boot-starter-tomcat</artifactId><br>                 </exclusion><br>             </exclusions>这个就好了,</p>
    
    2020-06-07 16:19:07
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
In-Flux Limiting for a Multi-Tenant Logging Service 立即下载
Run containerd as Container Runtime in production 立即下载
低代码开发师(初级)实战教程 立即下载

相关实验场景

更多