Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9273155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:02:46+00:00 2026-06-18T16:02:46+00:00

I have a Spring web project and I need load some classes after application

  • 0

I have a Spring web project and I need load some classes after application context has been initialized because those classes will eventually used in future. Thus, I try to preload them before use to improve performance.

How to do it ?

Please help.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T16:02:47+00:00Added an answer on June 18, 2026 at 4:02 pm

    To load a class into JVM it is enough simply to call Class.forName('com.foo.bar.MyClassToPreLoad') method.
    You can do it e.g. in your own implementation of javax.servlet.ServletContextListener and then register it in web.xml

    <listener>
        <listener-class>com.foo.bar.MyClassPreloadingContextListener</listener-class>
    </listener>
    

    Or you can do it in any of your Spring beans implementing org.springframework.beans.factory.InitializingBean interface. Or if you don’t want to implement interface you can do it in any bean method without arguments and register it as a init-method for this bean:

    <bean class="com.foo.bar.MyClassPreloadingBean" init-method="preloadClasses"/>
    

    See http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/beans.html#beans-factory-lifecycle-initializingbean for details.

    Or http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/beans.html#beans-postconstruct-and-predestroy-annotations if you prefer annotation based configuration.

    Hope it helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Spring web application. I would like to put some common piece of
I need something to happen immediately after Spring's application context is loaded. As I
I have some web-project (Spring MVC + Hibernate). For hibernate objects I am using
I have a pretty complex web-application where the whole DAO has been outsourced to
I need to load the i18n localization properties of my Spring web application as
I have a Spring 3.0.x web project that is displaying a page of links
I have a Spring Web MVC application that I'd like to serve a large,
I have a Spring Web application with an applicationContext.xml loaded through a ContextLoaderListener in
I have this web application using Spring Web Flow framework. In my main page
I am developing an application in Spring Web MVC where i need to execute

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.