Spring Mvc java.io.FileNotFoundException - ApplicationContext.xml

穿精又带淫゛_ 提交于 2019-12-06 12:24:35

In my case all I need to do is to move applicationContext.xml from

src\main\webapp\WEB-INF\

to

src\main\resources\.

i had to stick to using the /resources directory in the WEB-INF file or you can name it anything you want. The classpath looks at the WEB-INF directory however it scans the folders within that directory. I moved the applicationContext.xml and the servlet.xml files into the WEB-INF/resources directory, so yes it can be deleted from the root of the WEB-INF and there is no need to maintain two copies of an applicationContext.xml or servlet.xml files.

What You have to do is add your ApplicationContext.xml file in to your source directory. And then load spring configuration file without any path like this.

    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("ApplicationContext.xml");

it will work !!!

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