Spring - application Initialized twice?

前端 未结 5 873
别那么骄傲
别那么骄傲 2020-12-09 19:57

When I starts to run my spring application my tomcat , the ContextRefreshedEvent fires twice. Please see the StackTrace.

Dec 20, 2013 6:07:56 PM         


        
5条回答
  •  悲&欢浪女
    2020-12-09 20:29

    That's very normal. You have an application listener that loads a the context, and you have a servlet that loads on startup and loads the context also. Remove load on startup from the servlet declaration in web.xml. You web.xml will become tike this :

    
    
        SpringValidations
    
        
            index.jsp
        
    
        
            dispatcher
            org.springframework.web.servlet.DispatcherServlet
            
                contextConfigLocation
                /WEB-INF/dispatcher-servlet.xml
            
    
        
    
        
            dispatcher
            *.html
        
    
    
        
            contextConfigLocation
            /WEB-INF/applicationContext.xml
        
    
        
            org.springframework.web.context.ContextLoaderListener
        
    
        
            log4jConfigLocation
            /WEB-INF/classes/log4j.xml
        
    
        
            org.springframework.web.util.Log4jConfigListener
        
    
    
    

提交回复
热议问题