aspose file tools
The moose likes Other Application Frameworks and the fly likes Spring Config file Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Application Frameworks » Other Application Frameworks
Reply Bookmark "Spring Config file" Watch "Spring Config file" New topic
Author

Spring Config file

Lu Battist
Ranch Hand

Joined: Feb 17, 2003
Posts: 104
I'd like to use an absolute file path, but don't seem able to do so.
I should mention this is a stand-alone J2SE program, no Web-Container.

Anyone know a way to do this? I'm trying to use the following FileSystemXMLApplicationContext which seems to only allow relative file paths. Perhaps, I'm fairly new to Spring so perhaps there is an alternate way I've overlooked.



If I pass in "/user/appRoot/properties/projectX/projectX.xml", Spring will only look for it as a relative path off the current directory the program was launched from. So it prepends the current directory as in "/user/appRoot/scripts/user/appRoot/properties/projectX/projectX.xml" and causes an IOException. A relative path will work. As in "../properties/projectX/projectX.xml", but this isn't what I want to do.

I'd say that's fine if I had said "user/appRoot/properties/projectX/projectX.xml" but the '/' in front should indicate an absolute path, should it not?

I'm not against a relative path. If you put your configuration file in the same directory as the script that launches your application that's a beautiful thing. I just wish it had the flexibility to do both absolute and relative paths.
Jason Moors
Ranch Hand

Joined: Dec 04, 2001
Posts: 188
If you want absolute paths you need to prefix file:

For backward compatibilty reasons FileSystemXmlApplicationContext uses the relative to the current working directory, even if they start with a /

Therefore you must use the file: URL prefix to force the paths to be treated as UrlResources.



regards

Jason.
Lu Battist
Ranch Hand

Joined: Feb 17, 2003
Posts: 104
Thanks Jason! I'll give that a try.
 
 
subject: Spring Config file
 
Threads others viewed
Writing/Reading Files
writing a new file to the context root
NX: DB File Location in suncertify.properties
FileNotFound exception
Where should file path be?
MyEclipse, The Clear Choice