java 在 WildFly 10 中添加 jar 作为部署

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39122046/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 04:06:07  来源:igfitidea点击:

adding jars as deployment in WildFly 10

javaspringweb-applicationsdeploymentwildfly-10

提问by MDaniyal

Is there a way, we can deploy jars as a library/deployment in WildFly 10like we can do it in weblogicserver?. OR can we place the jars in any folder of server and define those dependencies as provided?

有没有办法,我们可以WildFly 10像在weblogic服务器中那样将 jar 部署为库/部署?或者我们可以将 jars 放在服务器的任何文件夹中并将这些依赖项定义为provided

采纳答案by MDaniyal

What I got the way to deploy jars on WildFly 10server rather than making part of the war file is define below:

jarWildFly 10服务器上部署s而不是制作War文件的一部分的方法定义如下:

1) Put all your jars in wildfly\modules\system\layers\base\com\abcProject\mainand place a file named module.xmlwith the following content:

1) 把你所有的 jars 放进去wildfly\modules\system\layers\base\com\abcProject\main并放置一个文件名module.xml,内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.3" name="com.abcProject">
<resources>
    <resource-root path="aspectjrt-1.6.8.jar"/>
    <resource-root path="aspectjweaver-1.6.8.jar"/>
    <resource-root path="aopalliance-1.0.jar"/>
    <resource-root path="guava-18.0.jar"/>
</resources>

<dependencies>
    <module name="javaee.api"/>
    <module name="org.apache.commons.logging"/>
    <module name="org.jboss.vfs"/>
</dependencies>

Where resourcesare all those jarspresent in your abcProject/mainfolder and dependenciesare all those jarson which your jarsare dependent and are present in wildfly\modules\system\layers\basefolders.

哪里resources是所有那些jars存在于您的abcProject/main文件夹,dependencies都是那些jars上你的jars依赖和存在于wildfly\modules\system\layers\base文件夹中。

2) Then in your project add a file named jboss-deployment-structure.xmlin WEB-INFfolder with the following conents:

2)然后在您的项目中添加一个jboss-deployment-structure.xmlWEB-INF文件夹中命名的文件,内容如下:

<?xml version="1.0"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<deployment>
    <dependencies>
        <module name="com.abcProject" >
            <imports>
                <include path="META-INF**"/>
                <include path="org**"/>
            </imports>
        </module>
    </dependencies>
</deployment>

3) Now set scopeof all those dependenciesin your pomfiles as providedthat you have placed jarsin abcProject/mainfolder.

3)现在设置scope所有这些dependencies在你的pom文件,provided你已经放置jarsabcProject/main文件夹中。

That's all now run your project it will get all jars from server and will not include in warfile during compilation.

这就是现在运行您的项目的全部内容,它将jar从服务器获取所有s,并且war在编译期间不会包含在文件中。

回答by Leo G.

To add external jars as a "library" in Jboss/Wildfly, you can define it as a module in your installation, or add it to an existing module.

要将外部 jar 添加为 Jboss/Wildfly 中的“库”,您可以在安装中将其定义为模块,或将其添加到现有模块中。

See this linkfor more details on how to add a module in Wildfly.

有关如何在 Wildfly 中添加模块的更多详细信息,请参阅此链接