开发者

Is it possible to keep referenced files inside the service itself?

开发者 https://www.devze.com 2023-03-04 18:21 出处:网络
I\'m working on a jax-ws service in Eclipse. At some point, this service opens and uses a couple of XSLT stylesheets.

I'm working on a jax-ws service in Eclipse. At some point, this service opens and uses a couple of XSLT stylesheets.

My question is, can you somehow import and keep these 2 files in the project itself, as you can with a library? For convenience' sake. I basically want my service to work as is, without having to go through the trouble of shipping the xslts along with the service but having to place them in different locations on the server, having to explain to people how and where t开发者_StackOverflow社区hey must go etc..

On a related note, how come when I make new File("D:\x.xslt");, the service looks for it in "C:\Users\Tudor\Desktop\eclipseJ2EE\eclipse\D:\x.xslt"? As in, *eclipse_path*/*fileName*. I would have understood, if it looked for the file in the root of the apache tomcat server; but not the installDir of eclipse... Anyway, how do I change that behaviour?


You can store the xslt file within your source classpath and load it via the Classloader.

If you are using Spring you can also use the ResourceLoader to load resources.

Its rarely a good idea to use File instances with relative paths directly, since within different server environments the base directory often differs.

Hope this helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消