Spring启动应用程序无法启动

时间:2016-06-08 18:11:04

标签: java spring-boot netflix-eureka

我有一个Spring Boot Web应用程序无法启动以下错误。 它是发现Eureka服务器的客户端应用程序。

请帮忙。感谢

Exception in thread "main" 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:133)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:474)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:690)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:322)
    at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:134)

EffectivePOM

  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-tomcat</artifactId>
    <version>1.2.8.RELEASE</version>
  </dependency>
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-velocity</artifactId>
    <version>1.2.8.RELEASE</version>
  </dependency>
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    <version>1.2.8.RELEASE</version>
  </dependency>

Java类

@Configuration
@SpringBootApplication
@EnableEurekaClient
@EnableScheduling

public class WebApplication extends SpringBootServletInitializer  {
    private final static Class<WebApplication> APPLICATION_CLASS = WebApplication.class;
    private static ApplicationContext ctx;
    @PersistenceContext
    private EntityManager em;

    @Autowired
    JdbcTemplate jdbcTemplate;
    static Connection connection;
    public static void main(String[] args) {        
        ctx = SpringApplication.run(WebApplication.class, args);                
    }   
    public static Connection getConnection(){
        return connection;
    }
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(APPLICATION_CLASS);
    }
}

0 个答案:

没有答案