Linux 通过命令行在 Jboss 7.0.1 中部署 war

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8421116/
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-08-06 03:32:31  来源:igfitidea点击:

Deploying war in Jboss 7.0.1 through Commandline

linuxjakarta-eejbosscentos5jboss7.x

提问by Ahmed

I have a war file and I need to deploy it on Jboss 7.0.1 Server. Now I have gone through the documentation, but didnt find any thing to deploy a war file. Moreover for deploying your build through command line you generally have to use maven. So do we need for the war as well? If so, does it affects the war file?

我有一个战争文件,我需要将它部署在 Jboss 7.0.1 服务器上。现在我已经浏览了文档,但没有找到任何部署战争文件的东西。此外,为了通过命令行部署您的构建,您通常必须使用 maven。那么我们也需要战争吗?如果是这样,它会影响war文件吗?

FYI : I am using linux (CentOs5)...

仅供参考:我正在使用 linux (CentOs5) ...

采纳答案by ddri

You can deploy a .warfile using the Management Command Line Interface. The specific documentation for it is located here: JBoss AS7 Admin Guide - Deployment, with the relevant sections per the below. You might also like to have a quick watch of the video: 5 Ways To Deploy Your Applications To JBoss AS7

您可以使用管理命令行界面部署.war文件。它的特定文档位于此处:JBoss AS7 管理指南 - 部署,以及以下相关部分。您可能还想快速观看视频:将应用程序部署到 JBoss AS7 的 5 种方法

CLI Deployment To A Managed Domain

CLI 部署到托管域

The process of distributing deployment binaries involves two steps: You need to upload the deployment to the repository from which the domain controller can distribute it's contents. In a second step you need to assign the deployment to one or more server groups:

分发部署二进制文件的过程包括两个步骤: 您需要将部署上传到存储库,域控制器可以从中分发其内容。第二步,您需要将部署分配给一个或多个服务器组:

Using the CLI you can do it one sweep:

使用 CLI,您可以一次性完成:

[domain@localhost:9999 /] deploy ~/Desktop/test-application.war
Either --all-server-groups or --server-groups must be specified.

[domain@localhost:9999 /] deploy ~/Desktop/test-application.war --all-server-groups
'test-application.war' deployed successfully.

[domain@localhost:9999 /] deploy --help
[...]

After you've uploaded the binary using the "deploy" command, it will be available to the domain controller and assigned to a server group:

使用“deploy”命令上传二进制文件后,它将可供域控制器使用并分配给服务器组:

[domain@localhost:9999 /] :read-children-names(child-type=deployment)
{
   "outcome" => "success",
   "result" => [
       "mysql-connector-java-5.1.15.jar",
       "test-application.war"
   ]
}

[domain@localhost:9999 /] /server-group=main-server-group/deployment=test-application.war:read-resource
{
   "outcome" => "success",
   "result" => {
       "enabled" => true,
       "name" => "test-application.war",
       "runtime-name" => "test-application.war"
   }
}

In a similar way it can be removed from the server group:

以类似的方式,它可以从服务器组中删除:

[domain@localhost:9999 /] undeploy test-application.war --all-relevant-server-groups
Successfully undeployed test-application.war.

[domain@localhost:9999 /] /server-group=main-server-group:read-children-names(child-type=deployment)
{
   "outcome" => "success",
   "result" => []
}

CLI Deployment To A Standalone Server

CLI 部署到独立服务器

Deployment on a standalone server works similar to the managed domain, just that the server-group associations don't exist. You can rely on the same CLI command as for a managed domain to deploy an application:

在独立服务器上部署的工作方式与托管域类似,只是不存在服务器组关联。您可以依赖与托管域相同的 CLI 命令来部署应用程序:

[standalone@localhost:9999 /] deploy ~/Desktop/test-application.war
'test-application.war' deployed successfully.

[standalone@localhost:9999 /] undeploy test-application.war
Successfully undeployed test-application.war.

CLI Deployment to Standalone Server (one liner Shell command)

CLI 部署到独立服务器(一个线性 Shell 命令)

You can deploy a WAR in one shot from the Shell as well. This is useful for Bash scripts or Unix aliases. NOTE: This exposes the password, so only use it for personal development instances. Ensure $JBOSS_HOME is set, and change Password and WAR file path & name below as needed:

您也可以从 Shell 一次性部署 WAR。这对于 Bash 脚本或 Unix 别名很有用。注意:这会暴露密码,因此仅将其用于个人开发实例。确保设置了 $JBOSS_HOME,并根据需要更改下面的密码和 WAR 文件路径和名称:

$ $JBOSS_HOME/bin/jboss-cli.sh -u=admin -p=MY_PASSWORD --controller=localhost:9990 --connect --command="deploy /path/to/MY_APP.war --force"

Footnote: As you would know, you've got the Management Console for deployment, as well as the deployment scanner. The former is popular as any GUI would be, but the latter is more for development. I try to use the CLI as much as possible, as the learning curve is well worth the effort for the power of batch scripting and the sheer scale of low level operations that are exposed by the CLI API. Very cool stuff. I should add for sake of transparency that I work on the AS/EAP documentation team, so I might be biased.

脚注:如您所知,您已经获得了用于部署的管理控制台以及部署扫描器。前者和任何 GUI 一样受欢迎,但后者更适合开发。我尝试尽可能多地使用 CLI,因为对于批处理脚本的强大功能和 CLI API 公开的低级操作的绝对规模而言,学习曲线非常值得。很酷的东西。为了透明起见,我应该添加我在 AS/EAP 文档团队工作的信息,所以我可能有偏见。

回答by Bandham Manikanta

Above answer confused me.. So, here is the solution which is simple and worked for me.

上面的答案让我很困惑..所以,这是一个简单且对我有用的解决方案。

  • Make sure jbossis already running. Commandps -ef | grep jboss
  • navigate to JBSS_HOME/bin/and open JBOSS CLI. Command to open CLI is./jboss-cli.sh.
  • Once CLI is opened. You'll see like this [disconnected /]. Now, run the command connect. It will show like this [standalone@localhost:9999 /]
  • now, do deployment using the below command. "deploy /YOUR_WAR_PATH.war". Example: "deploy /tmp/my_app.war"
  • 确保jboss已经在运行。命令ps -ef | grep jboss
  • 导航到JBSS_HOME/bin/并打开 JBOSS CLI。打开 CLI 的命令是./jboss-cli.sh.
  • 一旦 CLI 打开。你会看到这样[disconnected /]。现在,运行命令connect。它会显示这样[standalone@localhost:9999 /]
  • 现在,使用以下命令进行部署。 "deploy /YOUR_WAR_PATH.war". 例子:"deploy /tmp/my_app.war"

That's all we need to do.

这就是我们需要做的所有事情。

Happy Learning..

快乐学习..