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下的,导致了加载的是低版本的,而我本地是高版本的,问题解决了


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值