您可以使用CLI
. 此示例将端口从 8081 更改为 8080:
启动 CLI(在 中.../bin/
):
$ ./jboss-cli.sh
You are disconnected at the moment. Type 'connect' to connect to the server or 'help' for the list of supported commands.
连接
[disconnected /] connect
切换到目标区域
[standalone@localhost:9999 /] cd /socket-binding-group=standard-sockets/socket-binding=http
显示当前状态:
[standalone@localhost:9999 socket-binding=http] ls -l
ATTRIBUTE VALUE TYPE
bound true BOOLEAN
bound-address 127.0.0.1 STRING
bound-port 8081 INT
client-mappings undefined LIST
fixed-port false BOOLEAN
interface undefined STRING
multicast-address undefined STRING
multicast-port undefined INT
name http STRING
port 8081 INT
更改端口属性:
[standalone@localhost:9999 socket-binding=http] :write-attribute(name="port", value="8080")
{
"outcome" => "success",
"response-headers" => {
"operation-requires-reload" => true,
"process-state" => "reload-required"
}
}
请注意,进程状态是“需要重新加载”
再看一遍:
[standalone@localhost:9999 socket-binding=http] ls -l
ATTRIBUTE VALUE TYPE
bound true BOOLEAN
bound-address 127.0.0.1 STRING
bound-port 8081 INT
client-mappings undefined LIST
fixed-port false BOOLEAN
interface undefined STRING
multicast-address undefined STRING
multicast-port undefined INT
name http STRING
port 8080 INT
请注意,这里也bound-port
仍然是旧值。
所以回到根目录
[standalone@localhost:9999 subsystem=web] cd /
重新加载
[standalone@localhost:9999 /] :reload
{
"outcome" => "success",
"response-headers" => {"process-state" => "reload-required"}
}
这意味着重新加载仍在进行中,再次
[standalone@localhost:9999 /] :reload
{"outcome" => "success"}
现在 HTTP 连接器应该在新端口上侦听。
更新
该问题要求动态更改端口(JBoss 已启动并正在运行)。另一种选择是将端口写入配置文件 ( standalone.xml
)。这是静态的,但它可能也可以用于安装目的。