问题
I have created a spring MVC application. I'm working on spring security concepts. So I've created a context configuration file name webbsite-security.xml and I've given the same file location in the context configuration path. The application fails due to an exception stating that FILENOTFOUNDEXCEPTION(applicationContext.xml not found). Is it necessary that a file named applicationContext.xml should exits even though we use some other configuration files.
回答1:
Why would you want to call it anything else, it would go against the default standard spring way fo doing things. Just import the relevant config files into the default app context xml.
But if you want change it you must specifiy in your web.xml the following :
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/whatevever.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
来源:https://stackoverflow.com/questions/11519337/spring-context-configuration