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