Maven Deploy web application to WildFly
In Maven, we can use the official JBoss WildFly Maven Plugin to deploy a web application (war file) to the WildFly application server.
Technologies tested :
- 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. Deploy WAR To WildFly
1.1 Start WildFly in standalone mode.
$ ./wildfly-9.0.2.Final/bin/standalone.sh ========================================================================= JBoss Bootstrap Environment JBOSS_HOME: /home/mkyong/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.
<plugin> <groupId>org.wildfly.plugins</groupId> <artifactId>wildfly-maven-plugin</artifactId> <version>1.1.0.Alpha5</version> </plugin>
1.3 Deploy with mvn wildfly:deploy
... ... 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")
Access http://localhst:8080/spring4-mvc-maven-ajax-example-1.0-SNAPSHOT
1.4 Undeploy with mvn wildfly:undeploy
... ... 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/mkyong/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. Update web context
By default, the filename of the war file (in target folder) will be registered as the web context. To custom it, define a deployment name by configure the name option like this :
<plugin> <groupId>org.wildfly.plugins</groupId> <artifactId>wildfly-maven-plugin</artifactId> <version>1.1.0.Alpha5</version> <configuration> <hostname>127.0.0.1</hostname> <port>9990</port> <username>mkyong</username> <password>password</password> <name>spring4ajax.war</name> </configuration> </plugin>
In the above configuration, the spring4ajax will be the new web context path – http://localhst:8080/spring4ajax
Remember to add the .war suffix, otherwise, NO web context will be registered!
References
From:一号门
COMMENTS