Tomcat裏antiResourceLocking的作用和引起的一個問題 .

 

今天在論壇看到了一個網友的提問:

奇怪的問題,文件上傳到Tomcat下的temp目錄裏面了


雖然我肯定是配置的問題,不過我還真的沒有自己遇到這個。

不過還好,樓主真的在配置文件裏找到了問題,那就是 antiResourceLocking


我們先來看看這個 antiResourceLocking 到底是幹什麼的!

If true, Tomcat will prevent any file locking. This will significantly impact startup time of applications, but allows full webapp hot deploy and undeploy on platforms or configurations where file locking can occur. If not specified, the default value is false .

Please note that setting this to true has some side effects, including the disabling of JSP reloading in a running server: see Bugzilla 37668 .

Please note that setting this flag to true in applications that are outside the appBase for the Host (the webapps directory by default) will cause the application to be deleted on Tomcat shutdown. You probably don't want to do this, so think twice before setting antiResourceLocking=true on a webapp that's outside the appBase for its Host.


我大致翻譯一下:

如果這個參數爲true,那麼將組織任何文件鎖。這將明顯的影響應用的啓動時間,但允許webapps,可能發生鎖的平臺和配置下,支持完整的熱部署和熱卸載。如果不配置,默認值是false;

如果設置爲true,有一些副作用,包括屏蔽了JSP文件在運行服務器上的重新加載。

如果設置爲true,且部署在Host的AppBase目錄外面(默認是webapps),在Tomcat關閉的時候將導致應用被刪除。


最主要的就翻譯到這裏了。實際上,如果爲false,因爲存在鎖,在你重新發布的時候,可能出現部分代碼無法更新。因爲原始文件可能因爲被鎖住了,不能刪除。


當然,如果爲false,那麼部署的目錄就是和包名相同了。如果是false,則會每次都放到一個臨時目錄下面,一個temp目錄。這也是這個配置引發的一個副作用。


另外的一個類似的配置 antiJARLocking 是防止jar類庫被鎖定而無法刪除這個作用的。


每天努力工作,每天都有收穫。早上的經驗繼續有用,我先複製一份先。呵呵呵!

 

今天是個好日子,因爲明天就是週末了,希望我能迴天津,順便祝大家週末好心情。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章