通过命令行在 Jboss 7.0.1 中部署 war [英] Deploying war in Jboss 7.0.1 through Commandline

查看:78
本文介绍了通过命令行在 Jboss 7.0.1 中部署 war的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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?

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

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

推荐答案

您可以使用管理命令行界面部署 .war 文件.它的具体文档位于:JBoss AS7 Admin Guide -部署,相关部分如下.您可能还想快速观看视频:5 种将应用程序部署到 JBoss AS7 的方法

You can deploy a .war file 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

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:

使用 CLI,您可以一扫而过:

Using the CLI you can do it one sweep:

[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
[...]

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

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

[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 部署到独立服务器

在独立服务器上的部署与托管域类似,只是不存在服务器组关联.您可以依赖与托管域相同的 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:

[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 部署到独立服务器(一个 liner Shell 命令)

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

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:

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

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

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.

这篇关于通过命令行在 Jboss 7.0.1 中部署 war的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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