Google News
logo
Java Spring MVC - Interview Questions
Is it allowed to use multiple Spring configuration files in Spring MVC?
Yes, Spring allows to have multiple configuration files in one application.
 
There are mainly two ways to achieve this and those ways are mentioned below :
 
(i) The Developer has to declare all the files in the web.xml using the parameter :
 
<servlet>
        <servlet-name>Spring</servlet-name>
        <servlet-class>
            org.Springframework.web.servlet.DispatcherServlet
        </servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>
                WEB-INF/Spring-dao-hibernate.xml,
           </param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
</servlet>
     
<servlet-mapping>
        <servlet-name>Spring</servlet-name>
        <url-pattern>/</url-pattern>
</servlet-mapping>

 

(ii) The developer can import files into the existing configuration.
 
<beans>
    <import resource="Spring-dao-hibernate.xml"/>
</beans>

 

Advertisement