Spring Context Configuration

两盒软妹~` 提交于 2019-12-11 17:33:28

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!