How to override a class file from a library JAR in a Java web app
The answer depends upon your container, it is container dependent. In general, /WEB-INF/classes is preferred to classes in a jar file in WEB-INF/lib.
For Tomcat, the order is the following:
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
- System class loader classes
- /WEB-INF/classes of your web application
- /WEB-INF/lib/*.jar of your web application
- Common class loader classes
But if you're using a different container, you need to consult the documentation for that server.
结论是: /WEB-INF/classes比/WEB-INF/lib/*.jar有更高的优先级,系统会优先寻找classes folder内的文件,然后再寻找jar,因此在web application创建一个同名文件,编译后将被优先读取。。。
No comments:
Post a Comment