简体   繁体   English

Unitils @SpringApplicationContext-如何找到初始化Spring上下文所花费的时间?

[英]Unitils @SpringApplicationContext - how to find time taken to initialize spring context?

I am using unitils for testing. 我正在使用unitils进行测试。 I see more than 90 spring context refresh messages in the failsafe test reports. 我在故障安全测试报告中看到了90多个spring上下文刷新消息。 I need to know how much time is taken to initialize these spring contexts. 我需要知道花了多少时间来初始化这些spring上下文。 Unitils does not have proper logging, so not able to track it with framework logs. Unitils没有正确的日志记录,因此无法使用框架日志进行跟踪。

The @SpringApplicationContext is on top of the test class, so cannot go for logger in my own test class @SpringApplicationContext在测试类的顶部,因此无法在我自己的测试类中使用logger

Writing an advice or aware class or an interceptor will not help, as all these classes has to be registered in the spring xml and those beans which are registered in spring xml will be loaded only after the context is initialized 编写建议或感知类或拦截器将无济于事,因为所有这些类都必须在spring xml中注册,而那些在spring xml中注册的bean仅在上下文初始化后才加载

Writing an application listener class, we can catch only the ContextRefreshedEvent , that is when the context in loaded not initialized. 编写应用程序侦听器类时,我们只能捕获ContextRefreshedEvent ,即加载的上下文未初始化时。

Cannot catch the ContextStartedEvent because it is published when the ApplicationContext is started using the start() method on the ConfigurableApplicationContext interface . 无法捕获ContextStartedEvent因为它是在ConfigurableApplicationContext interface上使用start()方法start() ApplicationContext时发布的。 Whereas unitils dynamically creates new ClassPathXmlApplicationContext(..,..); unitils动态创建新的ClassPathXmlApplicationContext(..,..); to create the spring context (class:org.unitils.spring.util.ClassPathXmlApplicationContextFactory) 创建spring上下文(class:org.unitils.spring.util.ClassPathXmlApplicationContextFactory)

How do I calculate spring context initialization time? 如何计算Spring上下文初始化时间?

What about simple log4j logger? 那么简单的log4j记录器呢? When logging Spring info logs you can see ContexLoader initialization time. 在记录Spring信息日志时,您可以看到ContexLoader初始化时间。

17:25:48 INFO - ContextLoader - Root WebApplicationContext: initialization started 17:25:48信息-ContextLoader-根WebApplicationContext:开始初始化

17:25:53 INFO - ContextLoader - Root WebApplicationContext: initialization completed in 5325 ms 17:25:53信息-ContextLoader-根WebApplicationContext:初始化在5325毫秒内完成

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 与@SpringApplicationContext联合使用-匹配的通配符很严格,但是找不到元素'context:annotation-config'的声明 - Unitils with @SpringApplicationContext - The matching wildcard is strict, but no declaration can be found for element 'context:annotation-config' 如何在Spring Framework 4中初始化应用程序上下文 - How to initialize Application Context in Spring Framework 4 Spring 集成:SpringApplicationContext 在配置中调用@ServiceActivator 吗? - Spring integration : does SpringApplicationContext call @ServiceActivator in config? 使用unitils,dbunit和spring进行单元测试 - unit testing with unitils, dbunit and spring Tapestry-Spring-无法初始化上下文 - Tapestry - Spring - Cannot Initialize Context 如何从Spring上下文中将bean的属性初始化为其名称? - How to initialize bean's property to its name from Spring context? 如何在 Spring Boot 中记录 Rest Web 服务所花费的时间? - How to log time taken by Rest web service in Spring Boot? Spring测试时如何在上下文初始化之前初始化测试类? - How to initialize test class before context initialization while Spring testing? 如何在 Selenium TestNG 环境中初始化 Spring 应用程序上下文文件 - How to initialize Spring application context file in Selenium TestNG environment Spring 上下文层次结构:如何同时初始化子上下文 - Spring Context Hierarchy: How to initialize child contexts concurrently
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM