Hi,
I'm running the stand-alone "Hello World" example from "Spring In Action".
I'm loading the Spring configuration file from the classpath in a main method.
I have 2 questions:
Question 1)
This code: BeanFactory factory = new XmlBeanFactory(new FileInputStream("hello.xml"));
throws: Exception in thread "main" java.io.FileNotFoundException: hello.xml (The system cannot find the file specified)
but this code:
BeanFactory factory = new XmlBeanFactory(new FileInputStream("C:\\devrep\\spring01\\classes\\he llo.xml"));
does not.
This entry: C:\devrep\spring01\classes; is on my classpath
How do I specify a relative configuration file location?
Question 2)
The Spring 1.1.5 API says XmlBeanFactory(InputStream) is deprecated. Would someone post a snippet showing how to feed XmlBeanFactory an org.springframework.core.io.Resource instead?
Thanks for your forbearance,
Phil Hershkowitz
Announcement
Announcement Module
Collapse
No announcement yet.
Help loading Spring config file from classpath
Page Title Module
Move
Remove
Collapse
X
-
Help loading Spring config file from classpath
Tags: None
-
Have a look at the docs here in 3.2.1. The BeanFactory
It shows an example of using the ClassPathResource.
Leave a comment: