前天还没问题,今天启动突然就报这个错。重新从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);
}
}
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
根据你提供的错误信息,问题在于Spring Boot应用在启动时无法找到EmbeddedServletContainerFactory
bean,这导致嵌入式容器无法启动。这个异常通常是因为Spring Boot未能正确配置或找不到负责创建和配置嵌入式Web服务器(如Tomcat、Jetty等)的组件。
考虑到你的项目使用的是Spring Boot 1.5.8.RELEASE版本,这是一个相对旧的版本,但该版本应该默认包含了对Tomcat的支持,因此理论上不应该出现这个问题。不过,可以尝试以下几个解决方案来排查和解决此问题:
检查依赖管理:确保你的pom.xml
文件中没有遗漏或错误地排除了与嵌入式服务器相关的依赖。对于Spring Boot 1.5.x,Tomcat是默认的嵌入式服务器,你需要确认有如下依赖(或类似的声明)存在且未被误删或排除:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
这个starter POM自动包含了运行Web应用所需的Tomcat和其他相关依赖。
清理并重建项目:有时候,IDE或构建工具有可能因为缓存问题而没有正确地下载或更新依赖。尝试执行以下命令来清理并重新构建你的项目:
mvn clean install
gradlew clean build
或 ./gradlew clean build
(取决于你的操作系统)检查自定义配置:如果你有自定义的Spring配置类或者配置文件(如application.properties
或application.yml
),请检查是否有意或无意间覆盖了嵌入式服务器的配置,比如禁用了它或指定了一个不存在的容器类型。
查看日志详细信息:按照错误提示,尝试以debug
模式重新运行应用以获取更详细的日志信息。这可以通过设置JVM参数或在某些IDE中直接配置来实现。例如,在命令行下,你可以这样启动应用:
java -Ddebug=true -jar your-app.jar
或者如果使用Maven,可以在运行命令时添加-Dspring-boot.run.jvmArguments="-Ddebug"
。
检查环境差异:既然你在服务器上可以正常启动,而在本地不行,考虑一下环境差异,比如Java版本是否一致,是否存在环境变量或系统属性的不同影响到了应用的启动。
如果以上步骤都无法解决问题,建议检查是否有其他第三方库的引入可能与Spring Boot的默认配置产生了冲突,或者尝试升级到较新的Spring Boot版本(虽然这可能需要更多的迁移工作)。