title: Can not open beans.xml (config file) because does not exist
body: <blockquote>
    <p>Exception in thread "main"
    org.springframework.beans.factory.BeanDefinitionStoreException:
    IOException parsing XML document from class path resource
    [com/main/beans.xml]; nested exception is
    java.io.FileNotFoundException: class path resource
    [com/main/beans.xml] cannot be opened because it does not exist</p>
  </blockquote>
  
  <pre><code>ApplicationContext context = 
        new ClassPathXmlApplicationContext("com/main/beans.xml");
  </code></pre>
  
  <p>I have tried before with</p>
  
  <pre><code>ApplicationContext context = 
       new FileSystemXmlApplicationContext("src/main/java/com/main/beans.xml");
  </code></pre>
  
  <p>And it works well.</p>
  
  <p>How to do that relative to the classpath?</p>
  
  <p><strong>Note:</strong> classpath is in the build path</p>
  
  <hr>
  
  <p>In the example I'm following, it has the following structure and it works</p>
  
  <p><strong>Project structure</strong></p>
  
  <p><img src="https://i.stack.imgur.com/E9tO9.png" alt="Project structure"></p>
  
  <p><strong>Classpath</strong></p>
  
  <p><img src="https://i.stack.imgur.com/2drSZ.png" alt="Classpath"></p>
  
  <pre><code>ApplicationContext context = 
      new ClassPathXmlApplicationContext("com/caveofprogramming/spring/test/beans/beans.xml");
  </code></pre>