I’m starting to learn the Spring framework and when i run the application i get an IOException saying that the xml file does not exist but it is located in the root folder. Here’s the little code: package org.koushik.javabrains;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class DrawingApp {
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
Triangle triangle = (Triangle)context.getBean("triangle");
triangle.draw();
}
}
The xml:
<beans>
<bean id="triangle" class="org.koushik.javabrains.Triangle">
<property name="type" value="Equilateral"/>
</bean>
</beans>
Here’s how the project looks like:

This worked perfectly when i used the BeanFactory interface but with the ApplicationContext i get this error. I tried putting the xml file i the src folder but it didn’t work either. Thanks for the help
You need to put the spring.xml in your src folder, not the root folder, as ClassPathXmlApplicationContext reads from the classpath.