• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Spring Config file

 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Jason! I'll give that a try.
 
It's exactly the same and completely different as this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic