2

I want to use a relative to my project path for the directory attribute

<file:inbound-channel-adapter directory="{?relativePathHere?}" channel="In" >
    <int:poller id="poller" fixed-delay="5000" />
</file:inbound-channel-adapter>

I am a newbie in SI, could anybody provide the way how a relative(not absolute) path is used for the attribute?

Gary Russell
  • 166,535
  • 14
  • 146
  • 179
heroin
  • 2,148
  • 1
  • 23
  • 32

1 Answers1

3

Relative to what?

By default, it's relative to the current working directory...

directory="foo/bar"

will resolve to System.getProperty("user.dir") + "/foo/bar"

directory="/foo/bar"

is absolute: "/foo/bar"`

directory="classpath:foo/bar"

will resolve to foo/bar somewhere on the classpath.

EDIT:

To reference a directory in the user's home, you can use Spring Expression Language (SpEL) to get that property:

directory="#{systemProperties['user.home']}/foo/bar">
Gary Russell
  • 166,535
  • 14
  • 146
  • 179
  • 1
    Thanks for explanations. While not everything works in the way you have described. 1) ``directory="classpath:foo/bar"`` not working at all - exceptions while starting a tomcat server. 2) ``directory="/foo/bar"`` - absolute path works great. 3) ``directory="foo/bar"`` - suppose I'm user andrew on Linux machine. Then my user's folder is /home/andrew. Then ``directory="foo/bar"`` is not associated to /home/andrew/foo/bar. Please, help me here to understand your thought. As you see, for now I could only use absolute path successfully. – heroin Oct 04 '15 at 06:30
  • `"While not everything works in the way you have described. ..."` It works __exactly__ the way I described; when using the classpath: prefix you need to put the parent directory on tomcat's classpath. You can also use SpEL; see my edit. In future, please make your questions clearer, such as "how can I reference a directory in the user's home". – Gary Russell Oct 04 '15 at 13:56