Saving files across server restarts using Tomcat in Eclipse?
I have been trying to find answers to this question, and I'm currently baffled.
We are using Eclipse for development and testing, and the Tomcat 7 server is started from within Eclipse. As there are frequent changes to the code, it automatically restarts and reloads the Spring beans when changes are made to the source code. From what I see, it rebuilds the whole "WebContent" area for the webapp.
So, inside the app, I tried writing the output file images that are created into the tomcat location where it puts the wtbwebapps folder. However, since this seems to be re-generated every time you restart the server, there is no persistence to these files, and since I store the location of the file in my database, I'd like the file to be there when I restart the server over and over.
From my research, it seems that you can set up a "docbase" in the context for Tomcat ( Stack Overflow question ). Then I saw this: Eclipse thread and they say that the docbase attribute isn't supported in Eclipse.
So does anybody here have any idea where I can put these file where they'll still be available via the web? These images are basically the results of simulations that are run, and it's kind of necessary to have them available.
Thanks so much for any thoughts. I don't have code examples here because it seems to be totally a configuration thing. If there is any info开发者_运维百科 that I can provide that would help, I'd be happy to.
I recommend storing any app state in a location not directly accessible from the web and not as part of your app cod tree. Define a separate folder and then use an environment variable or similar to let your code find the app state folder. Then have your servlet handle request for images and fetch from app state folder.
精彩评论