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

今天启动用eureka的服务消费者时,一直出现问题。

SpringCloud报错:

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

解决方案:

网上的解决方案大多如下:

1.在main()方法的启动类的上方添加注解 @SpringBootApplication

2.可能是pom.xml中缺少依赖包

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

这些并没有解决我的问题,检查了几个小时后,发现是我的 .class 文件名称写错了。这个错误太低级了。。

将.class名称改为与类名一致就可以了。

@SpringBootApplication
@EnableDiscoveryClient
public class EurekaConsumerApplication {

    public static void main(String[] args) {
        new SpringApplicationBuilder(EurekaConsumerApplication.class).web(true).run(args);
    }
}

 

posted on 2018-09-12 10:00  乐之者v  阅读(5997)  评论(0编辑  收藏  举报

导航