【发布时间】:2013-01-17 10:29:09
【问题描述】:
我有一个 Spring Web 项目,我需要在初始化应用程序上下文后加载一些类,因为这些类最终将在未来使用。因此,我尝试在使用前预加载它们以提高性能。
怎么做?
请帮忙。
谢谢。
【问题讨论】:
-
请大家帮忙。谢谢。
-
ApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:applicationContext.xml"); GenericDAOImpl dao = (GenericDAOImpl) ctx.getBean("genericDaoImpl");类加载器 clsLoader = Thread.currentThread().getContextClassLoader(); clsLoader.loadClass(arg0);是这个还是有更好的方法?
-
请提供一些答案。
-
您的评论可能增加了混乱。您要预加载 bean 吗?使用 applicationContext 定义加载所有 bean - ApplicationContext 实现的默认行为是在启动时急切地预实例化所有单例 bean。
标签: java spring class loading applicationcontext