Maven - Stellen Sie eine Webanwendung für WildFly bereit
In Maven können wir die offiziellen JBossWildFly Maven Pluginverwenden, um eine Webanwendung (War-Datei) auf dem WildFly-Anwendungsserver bereitzustellen.
Getestete Technologien:
-
Maven 3.3.9
-
WildFly 9.0.2.final
-
WildFly Maven Plugin 1.1.0.Alpha5
P.S This Spring MVC web application will be used for this deployment test.
1. Stellen Sie WAR für WildFly bereit
1.1 Start WildFly in standalone mode.
$ ./wildfly-9.0.2.Final/bin/standalone.sh ========================================================================= JBoss Bootstrap Environment JBOSS_HOME: /home/example/Desktop/wildfly-9.0.2.Final JAVA: /opt/jdk/jdk1.8.0_66/bin/java ... Http management interface listening on http://127.0.0.1:9990/management ... Admin console listening on http://127.0.0.1:9990 ... WildFly Full 9.0.2.Final (WildFly Core 1.0.2.Final) started in 2260ms ...
1.2 Declares wildfly-maven-plugin
in the pom.xml
file.
pom.xml
org.wildfly.plugins wildfly-maven-plugin 1.1.0.Alpha5
1.3 Deploy with mvn wildfly:deploy
WildFly Terminal
... ... WFLYUT0021: Registered web context: /spring4-mvc-maven-ajax-example-1.0-SNAPSHOT ... WFLYSRV0010: Deployed "spring4-mvc-maven-ajax-example-1.0-SNAPSHOT.war" (runtime-name : "spring4-mvc-maven-ajax-example-1.0-SNAPSHOT.war")
1.4 Undeploy with mvn wildfly:undeploy
WildFly Terminal
... ... WFLYSRV0028: Stopped deployment spring4-mvc-maven-ajax-example-1.0-SNAPSHOT.war ... (runtime-name: spring4-mvc-maven-ajax-example-1.0-SNAPSHOT.war) in 50ms ... WFLYDR0002: Content removed from location /home/example/Desktop/wildfly-9.0.2.Final/ ... standalone/data/content/94/c65382716f33f1c7e506208ed21616815438b2/content ... WFLYSRV0009: Undeployed "spring4-mvc-maven-ajax-example-1.0-SNAPSHOT.war" ... (runtime-name: "spring4-mvc-maven-ajax-example-1.0-SNAPSHOT.war")
2. Aktualisieren Sie den Webkontext
Standardmäßig wird der Dateiname der Dateiwar
(im Zielordner) als Webkontext registriert. Definieren Sie zum Anpassen einen Bereitstellungsnamen, indem Sie die Optionname
wie folgt konfigurieren:
pom.xml
org.wildfly.plugins wildfly-maven-plugin 1.1.0.Alpha5 127.0.0.1 9990 example password spring4ajax.war
In der obigen Konfiguration istspring4ajax
der neue Webkontextpfad -http://localhst:8080/spring4ajax
Note
Denken Sie daran, das Suffix .war hinzuzufügen, da sonst KEIN Webkontext registriert wird!