由于缺少EmbeddedServletContainerFactory bean,无法启动EmbeddedWebApplicationContext

Maven构建成功,但是当我尝试运行它失败时:

Error: Could not find or load main class app.jar 

我有resources/META-INF/MANIFEST.MF

 Manifest-Version: 1.0 Main-Class: go.Application 

一切似乎都到位了。 怎么了?

的pom.xml

    org.apache.maven.plugins maven-jar-plugin 2.5   src/main/resources/META-INF/MANIFEST.MF      

UPDATE1

使用IntelliJ构建jar工件时也是如此。

UPDATE2

好的,我设法运行它,但现在我有:

 Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean. 

UPDATE3

通过添加到Application.java来实现它:

 @Bean public EmbeddedServletContainerFactory servletContainer() { TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory(); return factory; } 

好的,所以我正在打扰我……我有以下几点:

 /** * Main class. */ @SpringBootApplication public class Application { /** * Main entry point for the application. * * @param args The args to pass in */ public static void main(String[] args) { SpringApplication.run(Application.class, args); } } 

我所有的依赖都是正确的..

经过详尽的搜索后,我发现了以下内容:

http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#getting-started-first-application-executable-jar

因为我没有将spring boot parent作为我的父级,所以我必须在我的插件配置中包含执行部分,如下所示:

   org.springframework.boot spring-boot-maven-plugin  your.Application.fqdn.here ZIP     repackage     

有关其他信息,请参阅以下内容

http://docs.spring.io/spring-boot/docs/1.4.0.BUILD-SNAPSHOT/maven-plugin/usage.html