title: What is the best way to profile the spring container to learn how to optimize its start up time?
body: <p>I have an application that is getting fairly large, and the Spring start up time is about 20 seconds. For production use, this is fine, but for development, this is a big pain.</p>
  
  <p>What is a good profiling tool or approach that can give me precisely the information I need to figure out what is taking so long? Maybe it's something I can optimize?</p>
  
  <p>My application is a fairly typical spring/hibernate web app. There's about 50 database tables and several hundred beans (like 200-300... I didn't count). There's a few @Configurable beans. Lots of component scanning. I am also using Spring Security.</p>
  
  <p>I did some primitize profiling with log4j - just at the INFO setting. Here are some of the things that are taking a bit of time:</p>
  
  <ul>
  <li><em>INFO DefaultListableBeanFactory:555 - Pre-instantiating singletons</em> - <strong>2 seconds</strong></li>
  <li><em>INFO SessionFactoryImpl:202 - building session factory</em> - <strong>2 seconds</strong></li>
  <li><em>INFO HibernateTransactionManager:415 - Using DataSource [com.mchange.v2.c3p0.ComboPooledDataSource......] of Hibernate SessionFactory for HibernateTransactionManager</em> - <strong>7 seconds</strong></li>
  </ul>
  
  <p>There are a couple of things that take .5 to maybe 1 second at the most, but these 3 were the largest ones.</p>