Jetty如何处理具有不同依赖关系的同一个类的类加载? [英] How Jetty handles class loading with same class with different dependencies?

查看:171
本文介绍了Jetty如何处理具有不同依赖关系的同一个类的类加载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道当多个依赖路径可以导致同一个类时,码头如何处理.

I want to know how jetty handles when multiple dependency paths which can lead to same class.

例如,

Jetty预先与JSTL-1.2一起打包,但是我添加了一个依赖项来加载JSTL-1.2.4.在编译时,如果我断点测试它在eclipse中下载源代码,它会在1.2.4版本中中断.

Jetty comes pre-packaged with JSTL-1.2, but I added a dependency to load JSTL-1.2.4. At compile time, if I breakpoint test it downloading the source code in eclipse, it breaks at 1.2.4 version.

当有两个版本的类时,我想知道将传递哪个版本来生成JSP的字节码,比如说某些基类 JstlCoreTlv 依赖(一个预先包装的,即具有码头的JSTL 1.2和来自Maven依赖项1.2.4的JSTL)

I want to know which version will be passed to generate byte code of a JSP, when there are two versions of classes, say some base class JstlCoreTlv in dependency (one pre-packaged, that is JSTL 1.2 with jetty and one passed from maven dependency 1.2.4)

简而言之,我想知道码头是怎么做的.我想知道码头如何优先考虑预包装与以后添加的依赖关系.即使该版本比预先打包的版本旧,它也会覆盖并引用附加的依赖项吗?

In brief, I want to know How jetty is doing it. I want to know how jetty prioritizes pre-packaged vs dependencies added later. Even if the version is older than that of pre-packaged one, will it override and refer to added dependencies?

在这种情况下,我从码头文件中获得的信息不多.非常感谢您的帮助

I couldn't get much in this context from jetty documentation. Help is much appreciated

推荐答案

servlet规范要求:

The servlet specification require that:

  • WEB-INF/lib或WEB-INF/class中包含的类的优先级高于父类加载器(此处是jetty的类加载器)上的类.

来自

WEB-INF类可以替换Server类.

A WEB-INF class can replace a Server class.

这里的服务器类是j2ee标准的码头实现(来自

And the server class here is the jetty implementation of j2ee standard (code from jetty source code):

    /** Is the class a Server Class.
     * A Server class is a class that is part of the implementation of 
     * the server and is NIT visible to a webapplication. The web
     * application may provide it's own implementation of the class,
     * to be loaded from WEB-INF/lib or WEB-INF/classes 
     * @param clazz The fully qualified name of the class.
     * @return True if the class is a server class.
     */
    boolean isServerClass(Class<?> clazz);

您还可以通过调用以下命令来添加对服务器类的控制:

You can also add control of server class by calling:

  • org.eclipse.jetty.webapp.WebAppContext.setServerClasses(String Array)
  • org.eclipse.jetty.webapp.WebAppContext.addServerClass(String)

这篇关于Jetty如何处理具有不同依赖关系的同一个类的类加载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆