Wildfly Maven插件+热部署
Wildfly Maven plugin + hot deployment
我有一个 Java Spring 应用程序,在 Eclipse Mars 中配置,我是 运行 Wildfly 9 来自 Eclipse。我正在使用 wildfly-maven-plugin 部署到服务器。
这些是我遵循的步骤:
从 eclipse 启动服务器并执行 Maven 构建,这也会将应用程序部署到服务器。我可以在 "successful deployment" 服务器上看到大量日志,并且可以在浏览器中访问我的应用程序。它在“/standalone/data/content”下创建了一个文件夹,但没有 war 或在 "standalone/deployments"
下展开了 WAR
如果我更改一些代码并将其保存在 Eclipse 中,(我已选中自动发布复选框并在保存时构建),服务器日志显示:将部署 "myApp.war" 替换为部署 "myApp.war" 内容从位置 "standalone\data\content..."
移除
而且我看到在步骤 1 中创建的 prev 文件夹已删除,myApp.war 已添加到部署文件夹。但是现在我无法在浏览器中访问我的应用程序。
auto-deploy-exploded="true"
那是在 standalone.xml 的部分。
对于 Eclipse,您可以使用 JBoss 工具插件:http://tools.jboss.org/
wildfly-maven-plugin
使用管理操作部署应用程序。它不部署任何分解的内容,只部署存档。换句话说,您需要在重新部署之前重新创建部署存档,否则将看不到更改。
正如 @ozOli 所说,最好使用 JBoss 工具。
有一个开放的 issue 允许部署展开的内容。这目前仅建议用于 run
目标,但它也可能会扩展以部署爆炸内容。我认为部署爆炸式内容有效。
一般来说 "hot deployments" 的问题是源代码需要重新编译然后重新部署。 redploy 是注释的关键,需要重新扫描。
Wildfly 具有管理 REST 支持。不需要花哨的工具。
这是一个 BASH 脚本,用于 Wildfly 和 Glassfish 自动重新部署 Maven 项目,即。在 Eclipse 中使用自动编译时:
set -x
pubname=
usewar=
if [[ -z $pubname ]]; then
pubname=ROOT
fi
if [[ -z "$usewar" ]]; then
usewar=0
else
usewar=1
fi
if ! webappdir=$(ls -d `pwd`/target/*-SNAPSHOT); then
webappdir=$(pwd)
fi
iswildfly=0
ctxroot="/$pubname"
if [[ "$pubname" == "ROOT" ]]; then
ctxroot="/"
fi
port=4848
if curl http://localhost:9991/ ; then
port=9991
iswildfly=1
elif curl http://localhost:9990/ ; then
port=9990
iswildfly=1
fi
if (( usewar )); then
webappdir=$webappdir.war
if ! (( iswildfly )); then
webappdir="@"$webappdir
fi
fi
wildflycmd() {
local cmd=
curl --retry 100 --retry-delay 3 --retry-connrefused --digest -L -u admin:admin -D - http://localhost:$port/management \
--header "Content-Type: application/json" \
-d "$cmd"
}
if (( iswildfly )); then
wildflycmd '{"operation" : "composite", "address" : [], "steps" : [{"operation" : "undeploy", "address" : {"deployment" : "'$pubname'.war"}},{"operation" : "remove", "address" : {"deployment" : "'$pubname'.war"}}],"json.pretty":1}'
if (( usewar )); then
wildflycmd '{"operation" : "composite", "address" : [], "steps" : [{"operation" : "add", "address" : {"deployment" : "'$pubname'.war"}, "content" : [{"url" : "file:'$webappdir'"}]},{"operation" : "deploy", "address" : {"deployment" : "'$pubname'.war"}}],"json.pretty":1}'
else
wildflycmd '{"operation" : "composite", "address" : [], "steps" : [{"operation" : "add", "address" : {"deployment" : "'$pubname'.war"}, "content" : [{"path" : "'$webappdir'", "archive":"false"}]},{"operation" : "deploy", "address" : {"deployment" : "'$pubname'.war"}}],"json.pretty":1}'
fi
fi
inotifyEvents=""
if ! [[ "$(uname)" =~ ^CYGWIN ]]; then
inotifyEvents="-e close_write"
fi
while inotifywait $inotifyEvents -r $webappdir --excludei "\.(js|html|css)$" || :; do
if ! (( iswildfly )); then
curl -v -H 'Accept: application/json' \
-X POST \
-H 'X-Requested-By: loadr' \
-F force=true \
-F id=$webappdir \
-F isredeploy=true \
-F virtualservers=server \
-F contextRoot=$ctxroot \
-F name=$pubname \
http://localhost:$port/management/domain/applications/application
else
wildflycmd '{"operation" : "composite", "address" : [], "steps" : [{"operation" : "redeploy", "address" : {"deployment" : "'$pubname'.war"}}],"json.pretty":1}'
fi
done
只需使用 mvn clean wildfly:run
启动 Wildfly 实例即可。
来源:https://github.com/jjYBdx4IL/snippets/blob/master/java/jee_autodeploy.sh
我有一个 Java Spring 应用程序,在 Eclipse Mars 中配置,我是 运行 Wildfly 9 来自 Eclipse。我正在使用 wildfly-maven-plugin 部署到服务器。
这些是我遵循的步骤:
从 eclipse 启动服务器并执行 Maven 构建,这也会将应用程序部署到服务器。我可以在 "successful deployment" 服务器上看到大量日志,并且可以在浏览器中访问我的应用程序。它在“/standalone/data/content”下创建了一个文件夹,但没有 war 或在 "standalone/deployments"
下展开了 WAR如果我更改一些代码并将其保存在 Eclipse 中,(我已选中自动发布复选框并在保存时构建),服务器日志显示:将部署 "myApp.war" 替换为部署 "myApp.war" 内容从位置 "standalone\data\content..."
移除而且我看到在步骤 1 中创建的 prev 文件夹已删除,myApp.war 已添加到部署文件夹。但是现在我无法在浏览器中访问我的应用程序。
auto-deploy-exploded="true"
那是在 standalone.xml 的部分。
对于 Eclipse,您可以使用 JBoss 工具插件:http://tools.jboss.org/
wildfly-maven-plugin
使用管理操作部署应用程序。它不部署任何分解的内容,只部署存档。换句话说,您需要在重新部署之前重新创建部署存档,否则将看不到更改。
正如 @ozOli 所说,最好使用 JBoss 工具。
有一个开放的 issue 允许部署展开的内容。这目前仅建议用于 run
目标,但它也可能会扩展以部署爆炸内容。我认为部署爆炸式内容有效。
一般来说 "hot deployments" 的问题是源代码需要重新编译然后重新部署。 redploy 是注释的关键,需要重新扫描。
Wildfly 具有管理 REST 支持。不需要花哨的工具。
这是一个 BASH 脚本,用于 Wildfly 和 Glassfish 自动重新部署 Maven 项目,即。在 Eclipse 中使用自动编译时:
set -x
pubname=
usewar=
if [[ -z $pubname ]]; then
pubname=ROOT
fi
if [[ -z "$usewar" ]]; then
usewar=0
else
usewar=1
fi
if ! webappdir=$(ls -d `pwd`/target/*-SNAPSHOT); then
webappdir=$(pwd)
fi
iswildfly=0
ctxroot="/$pubname"
if [[ "$pubname" == "ROOT" ]]; then
ctxroot="/"
fi
port=4848
if curl http://localhost:9991/ ; then
port=9991
iswildfly=1
elif curl http://localhost:9990/ ; then
port=9990
iswildfly=1
fi
if (( usewar )); then
webappdir=$webappdir.war
if ! (( iswildfly )); then
webappdir="@"$webappdir
fi
fi
wildflycmd() {
local cmd=
curl --retry 100 --retry-delay 3 --retry-connrefused --digest -L -u admin:admin -D - http://localhost:$port/management \
--header "Content-Type: application/json" \
-d "$cmd"
}
if (( iswildfly )); then
wildflycmd '{"operation" : "composite", "address" : [], "steps" : [{"operation" : "undeploy", "address" : {"deployment" : "'$pubname'.war"}},{"operation" : "remove", "address" : {"deployment" : "'$pubname'.war"}}],"json.pretty":1}'
if (( usewar )); then
wildflycmd '{"operation" : "composite", "address" : [], "steps" : [{"operation" : "add", "address" : {"deployment" : "'$pubname'.war"}, "content" : [{"url" : "file:'$webappdir'"}]},{"operation" : "deploy", "address" : {"deployment" : "'$pubname'.war"}}],"json.pretty":1}'
else
wildflycmd '{"operation" : "composite", "address" : [], "steps" : [{"operation" : "add", "address" : {"deployment" : "'$pubname'.war"}, "content" : [{"path" : "'$webappdir'", "archive":"false"}]},{"operation" : "deploy", "address" : {"deployment" : "'$pubname'.war"}}],"json.pretty":1}'
fi
fi
inotifyEvents=""
if ! [[ "$(uname)" =~ ^CYGWIN ]]; then
inotifyEvents="-e close_write"
fi
while inotifywait $inotifyEvents -r $webappdir --excludei "\.(js|html|css)$" || :; do
if ! (( iswildfly )); then
curl -v -H 'Accept: application/json' \
-X POST \
-H 'X-Requested-By: loadr' \
-F force=true \
-F id=$webappdir \
-F isredeploy=true \
-F virtualservers=server \
-F contextRoot=$ctxroot \
-F name=$pubname \
http://localhost:$port/management/domain/applications/application
else
wildflycmd '{"operation" : "composite", "address" : [], "steps" : [{"operation" : "redeploy", "address" : {"deployment" : "'$pubname'.war"}}],"json.pretty":1}'
fi
done
只需使用 mvn clean wildfly:run
启动 Wildfly 实例即可。
来源:https://github.com/jjYBdx4IL/snippets/blob/master/java/jee_autodeploy.sh