Error creating bean with name 'tomcatEmbeddedServletContainerFactory ' (or a BeanPostProcessor involved) returned null
org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration$EmbeddedTomcat
org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration$EmbeddedTomcat
tomcatEmbeddedServletContainerFactory
问题:
org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tomcatEmbeddedServletContainerFactory' defined in class path resource [org/springframework/boot/autoconfigure/web/EmbeddedServletContainerAutoConfiguration$EmbeddedTomcat.class]: factory-bean 'org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration$EmbeddedTomcat' (or a BeanPostProcessor involved) returned null
解决办法:
解决过程:
刚开始看到这个报错,觉得莫名其妙,什么也没做,怎么就不行了。
看到是tomcatEmbeddedServletContainerFactory,就想会不是因为tomcat相关的配置错误,但看了下properties文件,除了这些,就没有web服务的配置了
就打了个断点,跟了下,也没有发现啥【陌生信息太多,迷失了。。。】
无意中使用关键词搜了下,发现在日志中出现的次数挺多。
根据报错信息的中“(or a BeanPostProcessor involved) returned null” 搜了下,看到这段:
想起之前为了梳理Spring启动过程,对各种场景的加载顺序时,也实现了一个BeanPostProcessor的实例。一个代码,果然 返回了null
详细日志:
2019-07-26 15:27:40.376 INFO 30704 --- [main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@78aab498: startup date [Fri Jul 26 15:27:40 CST 2019]; root of context hierarchy 2019-07-26 15:27:42.871 INFO 30704 --- [main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode! 2019-07-26 15:27:43.174 INFO 30704 --- [main] trationDelegate$BeanPostProcessorChecker : Bean 'taskExecutorConfig' of type [com.tangcheng.learning.thread.TaskExecutorConfig$$EnhancerBySpringCGLIB$$f66efd1e] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2019-07-26 15:27:43.178 INFO 30704 --- [main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 2019-07-26 15:27:43.892 INFO 30704 --- [main] trationDelegate$BeanPostProcessorChecker : Bean 'springInitBeanLifeCycleConfig' of type [com.tangcheng.learning.init.spring.SpringInitBeanLifeCycleConfig$$EnhancerBySpringCGLIB$$86d260bc] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2019-07-26 15:27:43.916 INFO 30704 --- [main] c.t.learning.init.spring.SpringInitBean : begin to execute Constructor Function 2019-07-26 15:27:43.939 INFO 30704 --- [main] c.t.learning.init.spring.SpringInitBean : Step-3调用。BeanNameAware.setBeanName springInitBean 2019-07-26 15:27:43.947 INFO 30704 --- [main] c.t.learning.init.spring.SpringInitBean : Step-4调用。BeanFactoryAware.setBeanFactory org.springframework.beans.factory.support.DefaultListableBeanFactory@273444fe: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.event.internalEventListenerProcessor,org.springframework.context.event.internalEventListenerFactory,demoApplication,org.springframework.boot.autoconfigure.internalCachingMetadataReaderFactory,restClient,conditionConfig,authorSettings,settingsConfig,eventBusConfig,observer1,observer2,subject,initBeanConfig,springInitBeanLifeCycleConfig,handler1Impl,handler2Impl,handlerService,redisDemo,echoBiz,quartzConfig,myJobFactory,echoJob,echoService,schedulerConfig,AServiceWithAopImpl,BServiceWithAopImpl,distributedLockAspect,distributeLockServiceImpl,defaultKeyGenerator,validatedServiceImpl,asyncTaskService,taskExecutorConfig,downController,helloController,httpMessageConverterTestController,invalidAopDemoController,MVC_DSL_TestController,mvcAnnotationDemoController,orderRestAPIController,requestParameterInitTestController,requestValidatedDemoController,serviceValidatedController,ctxCommandLine,globalExceptionHandler,randomStringConfig,redisConfig,restTemplateConfig,webConfig,indexController,weatherUserInfoExcelView,swaggerAutoConfiguration,swagger2Configuration,JSONPResponseBodyAdvice,fastJsonViewResponseBodyAdvice,fastJsonpResponseBodyAdvice,serviceModelToSwagger2MapperImpl,vendorExtensionsMapperImpl,parameterMapperImpl,modelMapperImpl,licenseMapperImpl,securityMapperImpl,apiListingReferenceScanner,apiDocumentationScanner,apiDescriptionReader,apiListingReader,cachingOperationReader,mediaTypeReader,apiListingScanner,apiModelReader,apiDescriptionLookup,operationModelsProvider,operationDeprecatedReader,responseMessagesReader,operationParameterReader,defaultTagsProvider,operationTagsReader,apiOperationReader,defaultOperationReader,operationParameterRequestConditionReader,operationParameterHeadersConditionReader,operationResponseClassReader,cachingOperationNameGenerator,parameterMultiplesReader,modelAttributeParameterExpander,parameterTypeReader,parameterRequiredReader,parameterDataTypeReader,parameterDefaultReader,parameterNameReader,expandedParameterBuilder,documentationPluginsBootstrapper,webMvcRequestHandlerProvider,documentationPluginsManager,queryStringUriTemplateDecorator,pathMappingDecorator,pathSanitizer,operationPathDecorator,cachingModelDependencyProvider,typeNameExtractor,propertyDiscriminatorBasedInheritancePlugin,xmlModelPlugin,schemaPluginsManager,cachingModelPropertiesProvider,objectMapperBeanPropertyNamingStrategy,accessorsProvider,fieldProvider,xmlPropertyPlugin,optimized,factoryMethodProvider,cachingModelProvider,defaultModelDependencyProvider,jacksonEnumTypeDeterminer,defaultModelProvider,apiModelPropertyPropertyBuilder,apiModelTypeNameProvider,apiModelBuilder,operationImplicitParameterReader,vendorExtensionsReader,swaggerOperationResponseClassReader,swaggerOperationModelsProvider,swaggerMediaTypeReader,operationHttpMethodReader,operationImplicitParametersReader,operationAuthReader,operationHiddenReader,operationSummaryReader,swaggerResponseMessageReader,operationNicknameIntoUniqueIdReader,operationPositionReader,operationNotesReader,swaggerOperationTagsReader,swaggerParameterDescriptionReader,swaggerExpandedParameterBuilder,swaggerApiListingReader,classOrApiAnnotationResourceGrouping,inMemorySwaggerResourcesProvider,apiResourceController,windowsListService,springfox.documentation.schema.configuration.ModelsConfiguration,typeResolver,modelBuilderPluginRegistry,modelPropertyBuilderPluginRegistry,typeNameProviderPluginRegistry,syntheticModelProviderPluginRegistry,springfox.documentation.spring.web.SpringfoxWebMvcConfiguration,defaults,resourceGroupCache,objectMapperConfigurer,jsonSerializer,descriptionResolver,methodResolver,documentationPluginRegistry,apiListingBuilderPluginRegistry,operationBuilderPluginRegistry,parameterBuilderPluginRegistry,expandedParameterBuilderPluginRegistry,resourceGroupingStrategyRegistry,operationModelsProviderPluginRegistry,defaultsProviderPluginRegistry,pathDecoratorRegistry,apiListingScannerPluginRegistry,springfox.documentation.swagger.configuration.SwaggerCommonConfiguration,springfox.documentation.swagger2.configuration.Swagger2DocumentationConfiguration,swagger2Module,swagger2ControllerMapping,springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration,expanderMinMax,expanderNotNull,expanderPattern,expanderSize,parameterMinMax,parameterNotNull,parameterPattern,parameterSize,minMaxPlugin,decimalMinMaxPlugin,sizePlugin,notNullPlugin,patternPlugin,org.springframework.boot.autoconfigure.condition.BeanTypeRegistry,swaggerProperties,uiConfiguration,createRestApi,eventBus,initBean,springInitBean,scheduler,org.springframework.scheduling.annotation.SchedulingConfiguration,org.springframework.context.annotation.internalScheduledAnnotationProcessor,org.springframework.scheduling.annotation.ProxyAsyncConfiguration,org.springframework.context.annotation.internalAsyncAnnotationProcessor,commandLineRunner,randomStringGenerator,redisTemplate,stringRedisTemplate,hashOperations,listOperations,setOperations,zSetOperations,restTemplate,fastJsonHttpMessageConverter,org.springframework.boot.autoconfigure.AutoConfigurationPackages,org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration,propertySourcesPlaceholderConfigurer,org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$Jackson2ObjectMapperBuilderCustomizerConfiguration,standardJacksonObjectMapperBuilderCustomizer,spring.jackson-org.springframework.boot.autoconfigure.jackson.JacksonProperties,org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor,org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.store,org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$JacksonObjectMapperBuilderConfiguration,jacksonObjectMapperBuilder,org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$JacksonObjectMapperConfiguration,jacksonObjectMapper,org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration,jsonComponentModule,org.springframework.boot.autoconfigure.websocket.WebSocketAutoConfiguration$TomcatWebSocketConfiguration,websocketContainerCustomizer,org.springframework.boot.autoconfigure.websocket.WebSocketAutoConfiguration,org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration$EmbeddedTomcat,tomcatEmbeddedServletContainerFactory,org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration,embeddedServletContainerCustomizerBeanPostProcessor,errorPageRegistrarBeanPostProcessor,org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration$DispatcherServletConfiguration,dispatcherServlet,spring.mvc-org.springframework.boot.autoconfigure.web.WebMvcProperties,org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration$DispatcherServletRegistrationConfiguration,dispatcherServletRegistration,org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration,org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration,defaultValidator,methodValidationPostProcessor,org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration,error,beanNameViewResolver,org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$DefaultErrorViewResolverConfiguration,conventionErrorViewResolver,org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration,errorAttributes,basicErrorController,errorPageCustomizer,preserveErrorControllerTargetClassPostProcessor,spring.resources-org.springframework.boot.autoconfigure.web.ResourceProperties,org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration,requestMappingHandlerAdapter,requestMappingHandlerMapping,mvcValidator,mvcContentNegotiationManager,mvcPathMatcher,mvcUrlPathHelper,viewControllerHandlerMapping,beanNameHandlerMapping,resourceHandlerMapping,mvcResourceUrlProvider,defaultServletHandlerMapping,mvcConversionService,mvcUriComponentsContributor,httpRequestHandlerAdapter,simpleControllerHandlerAdapter,handlerExceptionResolver,mvcViewResolver,mvcHandlerMappingIntrospector,org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter$FaviconConfiguration,faviconHandlerMapping,faviconRequestHandler,org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter,defaultViewResolver,viewResolver,welcomePageHandlerMapping,requestContextFilter,org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration,hiddenHttpMethodFilter,httpPutFormContentFilter,org.springframework.boot.actuate.autoconfigure.AuditAutoConfiguration$AuditEventRepositoryConfiguration,auditEventRepository,org.springframework.boot.actuate.autoconfigure.AuditAutoConfiguration,auditListener,org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration$RedisConfiguration,org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration$RedisConnectionConfiguration,redisConnectionFactory,org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration,spring.redis-org.springframework.boot.autoconfigure.data.redis.RedisProperties,org.springframework.boot.autoconfigure.info.ProjectInfoAutoConfiguration,spring.info-org.springframework.boot.autoconfigure.info.ProjectInfoProperties,org.springframework.boot.actuate.autoconfigure.InfoContributorAutoConfiguration,envInfoContributor,management.info-org.springframework.boot.actuate.autoconfigure.InfoContributorProperties,org.springframework.boot.actuate.autoconfigure.HealthIndicatorAutoConfiguration$DiskSpaceHealthIndicatorConfiguration,diskSpaceHealthIndicator,diskSpaceHealthIndicatorProperties,org.springframework.boot.actuate.autoconfigure.HealthIndicatorAutoConfiguration,healthAggregator,management.health.status-org.springframework.boot.actuate.autoconfigure.HealthIndicatorProperties,org.springframework.boot.actuate.autoconfigure.MetricRepositoryAutoConfiguration$FastMetricServicesConfiguration,counterBuffers,gaugeBuffers,actuatorMetricReader,counterService,gaugeService,org.springframework.boot.actuate.autoconfigure.MetricRepositoryAutoConfiguration,org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration,mbeanExporter,objectNamingStrategy,mbeanServer,org.springframework.boot.actuate.autoconfigure.PublicMetricsAutoConfiguration$TomcatMetricsConfiguration,tomcatPublicMetrics,org.springframework.boot.actuate.autoconfigure.PublicMetricsAutoConfiguration,systemPublicMetrics,metricReaderPublicMetrics,org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration$RequestMappingEndpointConfiguration,requestMappingEndpoint,org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration,environmentEndpoint,healthEndpoint,beansEndpoint,infoEndpoint,loggersEndpoint,metricsEndpoint,traceEndpoint,dumpEndpoint,autoConfigurationReportEndpoint,shutdownEndpoint,configurationPropertiesReportEndpoint,endpoints-org.springframework.boot.actuate.endpoint.EndpointProperties,org.springframework.boot.actuate.autoconfigure.EndpointMBeanExportAutoConfiguration,endpointMBeanExporter,auditEventsEndpoint,endpoints.jmx-org.springframework.boot.actuate.autoconfigure.EndpointMBeanExportProperties,org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration,serverProperties,duplicateServerPropertiesDetector,org.springframework.boot.actuate.autoconfigure.ManagementServerPropertiesAutoConfiguration,managementServerProperties,org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration$StringHttpMessageConverterConfiguration,stringHttpMessageConverter,spring.http.encoding-org.springframework.boot.autoconfigure.web.HttpEncodingProperties,org.springframework.boot.autoconfigure.web.JacksonHttpMessageConvertersConfiguration$MappingJackson2HttpMessageConverterConfiguration,mappingJackson2HttpMessageConverter,org.springframework.boot.autoconfigure.web.JacksonHttpMessageConvertersConfiguration,org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration,messageConverters,org.springframework.boot.actuate.autoconfigure.EndpointWebMvcManagementContextConfiguration,endpointHandlerMapping,mvcEndpoints,environmentMvcEndpoint,heapdumpMvcEndpoint,healthMvcEndpoint,loggersMvcEndpoint,metricsMvcEndpoint,logfileMvcEndpoint,auditEventMvcEndpoint,endpoints.health-org.springframework.boot.actuate.autoconfigure.HealthMvcEndpointProperties,endpoints.cors-org.springframework.boot.actuate.autoconfigure.EndpointCorsProperties,org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration$EndpointWebMvcConfiguration,org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration$ApplicationContextFilterConfiguration,applicationContextIdFilter,org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration,managementContextResolver,managementServletContext,org.springframework.boot.actuate.autoconfigure.MetricExportAutoConfiguration$MetricExportPropertiesConfiguration,spring.metrics.export-org.springframework.boot.actuate.metrics.export.MetricExportProperties,org.springframework.boot.actuate.autoconfigure.MetricExportAutoConfiguration$StatsdConfiguration,org.springframework.boot.actuate.autoconfigure.MetricExportAutoConfiguration,metricWritersMetricExporter,org.springframework.boot.actuate.autoconfigure.MetricFilterAutoConfiguration,metricsFilter,endpoints.metrics.filter-org.springframework.boot.actuate.autoconfigure.MetricFilterProperties,org.springframework.boot.actuate.autoconfigure.TraceRepositoryAutoConfiguration,traceRepository,org.springframework.boot.actuate.autoconfigure.TraceWebFilterAutoConfiguration,webRequestLoggingFilter,management.trace-org.springframework.boot.actuate.trace.TraceProperties,org.springframework.boot.autoconfigure.admin.SpringApplicationAdminJmxAutoConfiguration,springApplicationAdminRegistrar,org.springframework.boot.autoconfigure.aop.AopAutoConfiguration$JdkDynamicAutoProxyConfiguration,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.boot.autoconfigure.aop.AopAutoConfiguration,org.springframework.boot.autoconfigure.context.ConfigurationPropertiesAutoConfiguration,org.springframework.boot.autoconfigure.dao.PersistenceExceptionTranslationAutoConfiguration,persistenceExceptionTranslationPostProcessor,org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration,keyValueMappingContext,redisCustomConversions,redisReferenceResolver,redisConverter,redisKeyValueAdapter,redisKeyValueTemplate,org.springframework.data.web.config.ProjectingArgumentResolverRegistrar,projectingArgumentResolverBeanPostProcessor,org.springframework.data.web.config.SpringDataWebConfiguration,pageableResolver,sortResolver,org.springframework.data.web.config.SpringDataJacksonConfiguration,jacksonGeoModule,org.springframework.boot.autoconfigure.data.web.SpringDataWebAutoConfiguration,org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration,platformTransactionManagerCustomizers,spring.transaction-org.springframework.boot.autoconfigure.transaction.TransactionProperties,org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$ThymeleafResourceHandlingConfig,org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$ThymeleafWebLayoutConfiguration,layoutDialect,org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$ThymeleafDefaultConfiguration,templateEngine,org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$Thymeleaf3Configuration$Thymeleaf3ViewResolverConfiguration,thymeleafViewResolver,org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$Thymeleaf3Configuration$DefaultTemplateResolverConfiguration,defaultTemplateResolver,org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$Thymeleaf3Configuration,org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration,spring.thymeleaf-org.springframework.boot.autoconfigure.thymeleaf.ThymeleafProperties,org.springframework.boot.autoconfigure.web.HttpEncodingAutoConfiguration,characterEncodingFilter,localeCharsetMappingsCustomizer,org.springframework.boot.autoconfigure.web.MultipartAutoConfiguration,multipartConfigElement,multipartResolver,spring.http.multipart-org.springframework.boot.autoconfigure.web.MultipartProperties,org.springframework.boot.autoconfigure.web.WebClientAutoConfiguration$RestTemplateConfiguration,restTemplateBuilder,org.springframework.boot.autoconfigure.web.WebClientAutoConfiguration]; root of factory hierarchy 2019-07-26 15:27:43.951 INFO 30704 --- [main] c.t.learning.init.spring.SpringInitBean : Step-5调用。ApplicationContextAware.setApplicationContext org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@78aab498: startup date [Fri Jul 26 15:27:40 CST 2019]; root of context hierarchy 2019-07-26 15:27:43.953 INFO 30704 --- [main] c.t.learning.init.spring.SpringInitBean : begin to execute @PostConstruct 2019-07-26 15:27:43.954 INFO 30704 --- [main] c.t.learning.init.spring.SpringInitBean : Step-7调用。InitializingBean.afterPropertiesSet 2019-07-26 15:27:43.955 INFO 30704 --- [main] c.t.learning.init.spring.SpringInitBean : Step-7调用。类似地,如果bean使用init-method声明了初始化方法,该方法也会被调用 2019-07-26 15:27:43.956 INFO 30704 --- [main] c.t.learning.init.spring.SpringInitBean : begin to execute initMethod 2019-07-26 15:27:44.083 INFO 30704 --- [main] c.t.learning.init.spring.SpringInitBean : Step-6调用。BeanPostProcessor.postProcessBeforeInitialization bean=org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration$EmbeddedTomcat$$EnhancerBySpringCGLIB$$9aeb279f,beanName=org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration$EmbeddedTomcat 2019-07-26 15:27:44.104 INFO 30704 --- [main] c.t.learning.init.spring.SpringInitBean : Step-8调用。BeanPostProcessor.postProcessAfterInitialization bean=org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration$EmbeddedTomcat$$EnhancerBySpringCGLIB$$9aeb279f@67aaf882,beanName=org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration$EmbeddedTomcat 2019-07-26 15:27:44.109 WARN 30704 --- [main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tomcatEmbeddedServletContainerFactory' defined in class path resource [org/springframework/boot/autoconfigure/web/EmbeddedServletContainerAutoConfiguration$EmbeddedTomcat.class]: factory-bean 'org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration$EmbeddedTomcat' (or a BeanPostProcessor involved) returned null 2019-07-26 15:27:44.111 INFO 30704 --- [main] c.t.learning.init.spring.SpringInitBean : Step-10调用。DisposableBean.destroy 2019-07-26 15:27:44.114 INFO 30704 --- [main] c.t.learning.init.spring.SpringInitBean : Step-10调用。同样,如果bean使用destroy-method声明了销毁方法,该方法也会被调用 2019-07-26 15:27:44.116 INFO 30704 --- [main] c.t.learning.init.spring.SpringInitBean : begin to execute destroyMethod 2019-07-26 15:27:44.219 INFO 30704 --- [main] utoConfigurationReportLoggingInitializer : Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled. 2019-07-26 15:27:44.290 ERROR 30704 --- [main] o.s.boot.SpringApplication : Application startup failed org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tomcatEmbeddedServletContainerFactory' defined in class path resource [org/springframework/boot/autoconfigure/web/EmbeddedServletContainerAutoConfiguration$EmbeddedTomcat.class]: factory-bean 'org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration$EmbeddedTomcat' (or a BeanPostProcessor involved) returned null at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:139) ~[spring-boot-1.5.18.RELEASE.jar:1.5.18.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537) ~[spring-context-4.3.21.RELEASE.jar:4.3.21.RELEASE] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:124) ~[spring-boot-1.5.18.RELEASE.jar:1.5.18.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.18.RELEASE.jar:1.5.18.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.18.RELEASE.jar:1.5.18.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.18.RELEASE.jar:1.5.18.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.18.RELEASE.jar:1.5.18.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.18.RELEASE.jar:1.5.18.RELEASE] at com.tangcheng.learning.DemoApplication.main(DemoApplication.java:16) [classes/:na] Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tomcatEmbeddedServletContainerFactory' defined in class path resource [org/springframework/boot/autoconfigure/web/EmbeddedServletContainerAutoConfiguration$EmbeddedTomcat.class]: factory-bean 'org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration$EmbeddedTomcat' (or a BeanPostProcessor involved) returned null at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:374) ~[spring-beans-4.3.21.RELEASE.jar:4.3.21.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1178) ~[spring-beans-4.3.21.RELEASE.jar:4.3.21.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1072) ~[spring-beans-4.3.21.RELEASE.jar:4.3.21.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511) ~[spring-beans-4.3.21.RELEASE.jar:4.3.21.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481) ~[spring-beans-4.3.21.RELEASE.jar:4.3.21.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312) ~[spring-beans-4.3.21.RELEASE.jar:4.3.21.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.21.RELEASE.jar:4.3.21.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308) ~[spring-beans-4.3.21.RELEASE.jar:4.3.21.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-4.3.21.RELEASE.jar:4.3.21.RELEASE] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getEmbeddedServletContainerFactory(EmbeddedWebApplicationContext.java:201) ~[spring-boot-1.5.18.RELEASE.jar:1.5.18.RELEASE] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:164) ~[spring-boot-1.5.18.RELEASE.jar:1.5.18.RELEASE] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:136) ~[spring-boot-1.5.18.RELEASE.jar:1.5.18.RELEASE] ... 8 common frames omitted
Process finished with exit code 1
反思:
仔细从报错信息中获取线索,是解决问题是一个便捷的途径