INFO: Initializing Spring root WebApplicationContext log4j:3个WARN卡死的解决

本文介绍了一种常见的情况:启动Tomcat时程序卡在特定阶段且无任何输出的情况。文章详细解释了这一现象背后的原因,并提供了解决方案,包括如何正确配置log4j.properties文件以捕获错误日志。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

启动tomcat加载到这里卡死,没有任何输出,如下

INFO: Initializing Spring root WebApplicationContext
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

等很长时间没有反应,这时很大可能是后台已经报错了,可能是文件加载过成功出现了死循环,导致启动不了,

ssm框架中可能是spring报错,然而因为没有配置log4j.properties文件导致日志没有输出,从而看不到报错,此时

需要增加log4j.properties文件,这个log4j文件只要放在src目录下就可以,log4j组件会自动加载log4j.properties文件,

看到报错后可以针对报错信息进行修改。

附上一个比较通用的log4j.properties文件(点击下载)



____ _ __ _ _ /\ / ’ __ _ () __ __ _ \ \ \ ( ( )__ | '_ | '| | ’ / ` | \ \ \ \/ )| |)| | | | | || (| | ) ) ) ) ’ || .__|| ||| |_, | / / / / =========||==============|/=//// :: Spring Boot :: (v2.2.2.RELEASE) 2025-03-30 22:24:27.599 INFO 6052 — [ main] com.SpringbootSchemaApplication : Starting SpringbootSchemaApplication on DESKTOP-IBCAV8B with PID 6052 (D:\code\springboot55415\target\classes started by 卢民艺 in D:\code\springboot55415) 2025-03-30 22:24:27.601 INFO 6052 — [ main] com.SpringbootSchemaApplication : No active profile set, falling back to default profiles: default 2025-03-30 22:24:30.883 INFO 6052 — [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) 2025-03-30 22:24:30.888 INFO 6052 — [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2025-03-30 22:24:30.888 INFO 6052 — [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.29] 2025-03-30 22:24:30.955 INFO 6052 — [ main] o.a.c.c.C.[.[.[/springboot55415] : Initializing Spring embedded WebApplicationContext 2025-03-30 22:24:30.955 INFO 6052 — [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 3309 ms 2025-03-30 22:24:31.093 INFO 6052 — [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting… 2025-03-30 22:24:31.339 INFO 6052 — [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed. 2025-03-30 22:24:32.210 INFO 6052 — [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ‘/springboot55415’ 2025-03-30 22:24:32.212 INFO 6052 — [ main] com.SpringbootSchemaApplication : Started SpringbootSchemaApplication in 4.919 seconds (JVM running for 5.924)
03-31
2025.03.17 10:09:36|INFO |org.apache.juli.logging.DirectJDKLog|log()|173|Starting Servlet engine: [Apache Tomcat/9.0.33] 2025.03.17 10:09:36|INFO |org.apache.juli.logging.DirectJDKLog|log()|173|Initializing Spring embedded WebApplicationContext 2025.03.17 10:09:36|INFO |org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext|prepareWebApplicationContext()|284|Root WebApplicationContext: initialization completed in 2729 ms 2025.03.17 10:09:36|DEBUG|io.micrometer.core.util.internal.logging.InternalLoggerFactory|newDefaultFactory()|61|Using SLF4J as the default logging framework 2025.03.17 10:09:36|ERROR|org.springframework.boot.web.embedded.tomcat.TomcatStarter|onStartup()|61|Error starting Tomcat context. Exception: org.springframework.beans.factory.BeanCreationException. Message: Error creating bean with name 'servletEndpointRegistrar' defined in class path resource [org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfiguration$WebMvcServletEndpointManagementContextConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar]: Factory method 'servletEndpointRegistrar' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'healthEndpoint' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Unsatisfied dependency expressed through method 'healthEndpoint' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'healthContributorRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.health.HealthContributorRegistry]: Factory method 'healthContributorRegistry' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dbHealthContributor' defined in class path resource [org/springframework/boot/actuate/autoconfigure/jdbc/DataSourceHealthContributorAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.health.HealthContributor]: Factory method 'dbHealthContributor' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class 2025.03.17 10:09:36|INFO |org.apache.juli.logging.DirectJDKLog|log()|173|Stopping service [Tomcat] 2025.03.17 10:09:36|WARN |org.springframework.context.support.AbstractApplicationContext|refresh()|558|Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat 2025.03.17 10:09:36|INFO |org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener|logMessage()|136|
03-18
06:53:37.232 [main] INFO c.r.s.RuoYiSystemApplication - [logStartupProfileInfo,638] - The following 1 profile is active: "dev" 06:53:39.561 [main] INFO o.a.c.h.Http11NioProtocol - [log,173] - Initializing ProtocolHandler ["http-nio-9201"] 06:53:39.566 [main] INFO o.a.c.c.StandardService - [log,173] - Starting service [Tomcat] 06:53:39.566 [main] INFO o.a.c.c.StandardEngine - [log,173] - Starting Servlet engine: [Apache Tomcat/9.0.96] 06:53:39.678 [main] INFO o.a.c.c.C.[.[.[/] - [log,173] - Initializing Spring embedded WebApplicationContext 06:53:39.836 [main] WARN c.b.d.d.DynamicRoutingDataSource - [afterPropertiesSet,243] - dynamic-datasource initial loaded [0] datasource,Please add your primary datasource or check your configuration 06:53:40.806 [main] WARN o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext - [refresh,599] - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sysDictDataController': Unsatisfied dependency expressed through field 'dictTypeService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sysDictTypeServiceImpl': Invocation of init method failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.ruoyi.system.mapper.SysDictDataMapper.selectDictDataList 06:53:40.826 [main] INFO c.b.d.d.DynamicRoutingDataSource - [destroy,215] - dynamic-datasource start closing .... 06:53:40.826 [main] INFO c.b.d.d.DynamicRoutingDataSource - [destroy,219] - dynamic-datasource all closed success,bye 06:53:40.828 [main] INFO o.a.c.c.StandardService - [log,173] - Stopping service [Tomcat] 06:53:40.915 [main] ERROR o.s.b.SpringApplication - [reportFailure,818] - Application run failed org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sysDictDataController': Un
03-12
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值