当前位置:编程学习 > JAVA >>

Spring在加载时重复加载多次问题

我用的是apache mina做服务器  里面配置了几个Spring的xml文件
我启动SpringBeanFactory.init();加载Spring文件时 它连续重新加载了3次这是什么问题呢
加载Spring时如下
10:47:35 CST 2011]; root of context hierarchy
2011-12-30 10:47:35 INFO  XmlBeanDefinitionReader:315 - Loading XML bean definitions from file [E:\worksapce\GameServer\bin\context\context-action.xml]
2011-12-30 10:47:35 INFO  XmlBeanDefinitionReader:315 - Loading XML bean definitions from file [E:\worksapce\GameServer\bin\context\context-cache.xml]
2011-12-30 10:47:35 INFO  XmlBeanDefinitionReader:315 - Loading XML bean definitions from file [E:\worksapce\GameServer\bin\context\context-common.xml]
2011-12-30 10:47:35 INFO  XmlBeanDefinitionReader:315 - Loading XML bean definitions from file [E:\worksapce\GameServer\bin\context\context-manager.xml]
2011-12-30 10:47:35 INFO  XmlBeanDefinitionReader:315 - Loading XML bean definitions from file [E:\worksapce\GameServer\bin\context\context-rmi.xml]
2011-12-30 10:47:35 INFO  XmlBeanDefinitionReader:315 - Loading XML bean definitions from file [E:\worksapce\GameServer\bin\context\context-sche易做图ng.xml]
2011-12-30 10:47:35 INFO  PropertyPlaceholderConfigurer:177 - Loading properties file from class path resource [properties/project.properties]
2011-12-30 10:47:35 INFO  DefaultListableBeanFactory:537 - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@18f51f: defining beans [gameAction,roleAction,skillAction,sceneAction,petAction,friendAction,mailAction,itemAction,missionAction,guildAction,teamAction,duplicateAction,horseAction,systemAction,receiveRewardAction,rankAction,commonDataCache,missionDataCache,npcDataCache,itemDataCache,skillDataCache,duplicateDataCache,roleCache,petCache,tradeCache,teamCache,missionType,propertyConfigurer,messageSource,playerManager,roleManager,friendManager,mailManager,bagManager,storeManager,itemManager,makeItemManager,npcShopManager,shopManager,tradeManager,skillManager,missionManager,petManager,petHatchManager,teamManager,guildManager,guildMemberManager,horseManager,holdManager,receiveRewardManager,rankManager,talismanManager,commonDataService,playerService,roleService,friendService,mailService,itemService,skillService,missionService,petService,cacheService,teamService,guildService,startQuertz,gameTask,executeByDailyTask,executeByDailyTaskTrigger,updateSpTask,updateSpTaskTrigger]; root of factory hierarchy
2011-12-30 10:47:35 INFO  ClassPathXmlApplicationContext:454 - Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@162e295: startup date [Fri Dec 30 10:47:35 CST 2011]; root of context hierarchy
2011-12-30 10:47:35 INFO  XmlBeanDefinitionReader:315 - Loading XML bean definitions from file [E:\worksapce\GameServer\bin\context\context-action.xml]
2011-12-30 10:47:35 INFO  XmlBeanDefinitionReader:315 - Loading XML bean definitions from file [E:\worksapce\GameServer\bin\context\context-cache.xml]
2011-12-30 10:47:35 INFO  XmlBeanDefinitionReader:315 - Loading XML bean definitions from file [E:\worksapce\GameServer\bin\context\context-common.xml]
2011-12-30 10:47:35 INFO  XmlBeanDefinitionReader:315 - Loading XML bean definitions from file [E:\worksapce\GameServer\bin\context\context-manager.xml]
2011-12-30 10:47:36 INFO  XmlBeanDefinitionReader:315 - Loading XML bean definitions from file [E:\worksapce\GameServer\bin\context\context-rmi.xml]
2011-12-30 10:47:36 INFO  XmlBeanDefinitionReader:315 - Loading XML bean definitions from file [E:\worksapce\GameServer\bin\context\context-sche易做图ng.xml]
2011-12-30 10:47:36 INFO  PropertyPlaceholderConfigurer:177 - Loading properties file from class path resource [properties/project.properties]
2011-12-30 10:47:36 INFO  DefaultListableBeanFactory:537 - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@92dcdb: defining beans [gameAction,roleAction,skillAction,sceneAction,petAction,friendAction,mailAction,itemAction,missionAction,guildAction,teamAction,duplicateAction,horseAction,systemAction,receiveRewardAction,rankAction,commonDataCache,missionDataCache,npcDataCache,itemDataCache,skillDataCache,duplicateDataCache,roleCache,petCache,tradeCache,teamCache,missionType,propertyConfigurer,messageSource,playerManager,roleManager,friendManager,mailManager,bagManager,storeManager,itemManager,makeItemManager,npcShopManager,shopManager,tradeManager,skillManager,missionManager,petManager,petHatchManager,teamManager,guildManager,guildMemberManager,horseManager,holdManager,receiveRewardManager,rankManager,talismanManager,commonDataService,playerService,roleService,friendService,mailService,itemService,skillService,missionService,petService,cacheService,teamService,guildService,startQuertz,gameTask,executeByDailyTask,executeByDailyTaskTrigger,updateSpTask,updateSpTaskTrigger]; root of factory hierarchy
2011-12-30 10:47:36 INFO  QuartzScheduler:209 - Quartz Scheduler v.1.6.0 created.
2011-12-30 10:47:36 INFO  RAMJobStore:141 - RAMJobStore initialized.
2011-12-30 10:47:36 INFO  StdSchedulerFactory:1208 - Quartz scheduler 'startQuertz' initialized from an externally provided properties instance.
2011-12-30 10:47:36 INFO  StdSchedulerFactory:1212 - Quartz scheduler version: 1.6.0
2011-12-30 10:47:36 INFO  QuartzScheduler:2065 - JobFactory set to: org.springframework.sche易做图ng.quartz.AdaptableJobFactory@e06703
2011-12-30 10:47:36 INFO  DefaultLifecycleProcessor:326 - Starting beans in phase 2147483647
2011-12-30 10:47:36 INFO  SchedulerFactoryBean:650 - Starting Quartz Scheduler now
2011-12-30 10:47:36 INFO  QuartzScheduler:455 - Scheduler startQuertz_$_NON_CLUSTERED started.
2011-12-30 10:47:36 INFO  QuartzScheduler:209 - Quartz Scheduler v.1.6.0 created.
2011-12-30 10:47:36 INFO  RAMJobStore:141 - RAMJobStore initialized.
2011-12-30 10:47:36 INFO  StdSchedulerFactory:1208 - Quartz scheduler 'startQuertz' initialized from an externally provided properties instance.
2011-12-30 10:47:36 INFO  StdSchedulerFactory:1212 - Quartz scheduler version: 1.6.0
2011-12-30 10:47:36 INFO  QuartzScheduler:2065 - JobFactory set to: org.springframework.sche易做图ng.quartz.AdaptableJobFactory@1541147
2011-12-30 10:47:36 INFO  DefaultLifecycleProcessor:326 - Starting beans in phase 2147483647
2011-12-30 10:47:36 INFO  SchedulerFactoryBean:650 - Starting Quartz Scheduler now
2011-12-30 10:47:36 INFO  QuartzScheduler:455 - Scheduler startQuertz_$_NON_CLUSTERED started.
2011-12-30 10:47:36 INFO  QuartzScheduler:209 - Quartz Scheduler v.1.6.0 created.
2011-12-30 10:47:36 INFO  RAMJobStore:141 - RAMJobStore initialized.
2011-12-30 10:47:36 INFO  StdSchedulerFactory:1208 - Quartz scheduler 'startQuertz' initialized from an externally provided properties instance.
2011-12-30 10:47:36 INFO  StdSchedulerFactory:1212 - Quartz scheduler version: 1.6.0
2011-12-30 10:47:36 INFO  QuartzScheduler:2065 - JobFactory set to: org.springframework.sche易做图ng.quartz.AdaptableJobFactory@44d990
2011-12-30 10:47:36 INFO  DefaultLifecycleProcessor:326 - Starting beans in phase 2147483647
2011-12-30 10:47:36 INFO  SchedulerFactoryBean:650 - Starting Quartz Scheduler now
2011-12-30 10:47:36 INFO  QuartzScheduler:455 - Scheduler startQuertz_$_NON_CLUSTERED started.

他的bean加载了3次  应该只加载一次的  请问下各位大大这是撒问题啊 --------------------编程问答-------------------- 加载多少次的是你代码里面控制的,找找代码 --------------------编程问答-------------------- public class InitApplicationContext {
    private static ApplicationContext ac;

    public static ApplicationContext getAc() {
init();
return ac;
    }

    public static void init() {
if (ac == null)
    ac = new ClassPathXmlApplicationContext("bean.xml");
    }
} --------------------编程问答-------------------- SpringBeanFactory代码贴出来

另外  这个方法要同步
public static void init() {
if (ac == null)
ac = new ClassPathXmlApplicationContext("bean.xml");
  }
}
补充:Java ,  Java EE
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,