春季启动非Web应用程序,当启动它具有以下错误关于春天开机如何禁用网络环境中正常
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:185) ~[spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
然后我尝试以下方式
new SpringApplication().setWebEnvironment(false);
然后启动它仍然有以上错误。
然后试图
@SpringBootApplication(exclude={SpringDataWebAutoConfiguration.class})
但仍然有同样的错误。
最后我想补充以下配置application.properties
spring.main.web-environment=false
这一次它的工作原理。
为什么前两种方式无法正常工作?
后
spring-boot-starter-web
依赖实际的代码不是片段......有在'main'方法中有更多的行。所以发布应用程序类。 –尝试此'@SpringBootApplication(排除= {EmbeddedServletContainerAutoConfiguration.class, WebMvcAutoConfiguration.class})' 作为 [参考](http://stackoverflow.com/questions/32078015/spring-boot-enable-disable-embedded -Tomcat-与知名度) –
@SanjayRawat还是不行,请参阅https://github.com/zhugw/spring-boot-disable-web-environment – zhuguowei