Note that there are some explanatory texts on larger screens.

plurals
  1. POSpring Dependancy Injection: FileNotFound Exception
    primarykey
    data
    text
    <p><img src="https://i.stack.imgur.com/nt0k4.png" alt="enter image description here"></p> <p>I'm learning spring dependency injection. I have 2 types of code. One works and one doesn't... But, they both work for the person who made the tutorial.</p> <p>The commented code gives me the error shown below.</p> <pre><code> @SuppressWarnings("deprecation") public static void main(String[] args) { //ApplicationContext factory = new ClassPathXmlApplicationContext("Beans.xml"); //The code below works BeanFactory factory = new XmlBeanFactory(new FileSystemResource("Beans.xml")); HelloWorld obj = (HelloWorld) factory.getBean("helloworld"); obj.getMessage(); } </code></pre> <p>Beans.xml </p> <pre><code> &lt;?xml version="1.0"?&gt; &lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:jdbc="http://www.springframework.org/schema/jdbc" xsi:schemaLocation=" http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd "&gt; &lt;bean id="helloworld" class="com.vulab.hellow.HelloWorld"&gt; &lt;property name="message" value="Hello World" /&gt; &lt;/bean&gt; &lt;/beans&gt; </code></pre> <p>Error message when I use <em>ApplicationContext</em></p> <p>Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [Beans.xml]; nested exception is java.io.FileNotFoundException: class path resource [Beans.xml] cannot be opened because it does not exist</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload