Debug時候發現的同名jar包加載問題

tomcat debug的時候發現,本地的代碼和測試環境不一樣,導致有些行無法加斷點。

經詢問QA,兩部分代碼都是trunk的,由於採取的是maven父子工程的形式,所以懷疑是自己的jar包問題,發現webapp的lib下有多個同名的jar包,只是版本不同。


搜了一些資料,當tomcat發現一個class文件沒加載的時候,按照官方文檔給出的順序:


Therefore, from the perspective of a web application, class or resource loading looks in the following repositories, in this order:

  • Bootstrap classes of your JVM
  • /WEB-INF/classes of your web application
  • /WEB-INF/lib/*.jar of your web application
  • System class loader classes (described above)
  • Common class loader classes (described above)

If the web application class loader is configured with <Loader delegate="true"/> then the order becomes:

  • Bootstrap classes of your JVM
  • System class loader classes (described above)
  • Common class loader classes (described above)
  • /WEB-INF/classes of your web application
  • /WEB-INF/lib/*.jar of your web application

在相同目錄下,加載到的第一個就是最終加載的那個。


而我們的部署腳本是cp過去,並沒有先刪除lib下的,導致了加載的是低版本的,而我本地是高版本的,問題解決了


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