在Wildfly中,在我的WAR中包含JAR文件与通过jboss-deployment-structure.xml链接到它之间有区别吗? [英] In Wildfly, is there a difference between including a JAR file in my WAR as opposed to linking to it via jboss-deployment-structure.xml?

查看:114
本文介绍了在Wildfly中,在我的WAR中包含JAR文件与通过jboss-deployment-structure.xml链接到它之间有区别吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Java 8中使用Wildfly11.如果我部署两个具有相同库的WAR文件

/WEB-INF/lib/javassist-3.18.1-GA.jar

像这样将它们包含在/WEB-INF/jboss-deployment-structure.xml中是否有任何优势

<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
        <deployment>
                <dependencies>
            ...
                        <module name="org.javassist" />

与在我的WAR文件中包含JAR相对?也就是说,是否由于类加载或任何类似的优势而减少了内存?

解决方案

在内存或性能方面(JBoss模块声称可以做到),它具有更多优势,我认为JBoss模块更多地是为了利用模块的重用性,或者同一模块的单独版本.

如果您检查文件系统中JBoss模块的结构,它会记住maven存储库样式,通过这种方式,您可以更轻松地查看可用的模块和版本,或者可以使用JBoss AS的相同工具来检查依赖关系,作为CLI或Web控制台.

如果您有一个应用程序,但无法扩展特定框架/库的版本,则可以使用它,也可以将其他应用程序与同一库的其他版本一起使用.我知道将jar嵌入到应用程序中时可以达到相同的效果,但是您必须在所有应用程序中都做同样的事情,使用JBoss模块,您只需声明依赖项,应用程序就会更轻量.

在JBoss模块中,您配置的每个jar都是一个模块,并且每个模块都有自己的类加载器(模块化类加载器),并且每个类加载器都准确地知道它必须加载哪些类(以及相关性(如果适用)).平面类加载器(分层),用于加载所有类.这种体系结构使JBoss模块更快(基本上是因为它是一种与祖先JDK类加载器相同的新方法).

在此链接中,您可以查看更具体的指南解释更多概念的JBoss模块肯定具有更好的解释.

在此链接中,您可以找到简短的评论和一对示例.

希望这会有所帮助.

I'm using Wildfly 11 with Java 8. If I deploy two WAR files with identical libraries

/WEB-INF/lib/javassist-3.18.1-GA.jar

Is there any advantage to including these libraries in the /WEB-INF/jboss-deployment-structure.xml like so

<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
        <deployment>
                <dependencies>
            ...
                        <module name="org.javassist" />

as opposed to including the JAR in my WAR files? That is, do I cut down on memory due to class loading or any similar advantage?

解决方案

More than any advantage in memory or performance (that JBoss modules claims it can do), i think JBoss modules are more for take advantage of reuse of modules, or separate versions of the same module.

If you check the structure of the JBoss modules in file system, it remembers maven repository style, in this way you can review more easily the modules and versions available, or you can check the dependencies with the same tools of JBoss AS, as CLI or the Web console.

If you have an application and you can't scale a version of a specific framework/library you can stay with it, and you can have other applications with other versions of the same library. I know you can reach the same when you embed your jars into your application, but you have to do the same thing in all of your apps, with JBoss modules you just have to declare your dependencies and your application will be more lightweight.

In JBoss modules every jar you configure are a module, and every module has its own class loader(modular class loader), and every class loader knows exactly what classes it has to load (and its dependencies if apply), against a flat class loader (hierarchical), that loads all classes. This architecture makes JBoss modules faster (basically because is a new way to do the same thing of its ancestor, the JDK class loader).

In this link, you can check a more specific guide of JBoss modules that explains more concepts and surely has a better explanation.

In this link, you can find a short review and a pair of examples.

Hope this helps.

这篇关于在Wildfly中,在我的WAR中包含JAR文件与通过jboss-deployment-structure.xml链接到它之间有区别吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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