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.

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 :

  1. Maven 3.3.9
  2. WildFly 9.0.2.final
  3. 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.

pom.xml
  <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

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")

Access http://localhst:8080/spring4-mvc-maven-ajax-example-1.0-SNAPSHOT

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/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 :

pom.xml
  <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

Note
Remember to add the .war suffix, otherwise, NO web context will be registered!

References

  1. WildFly Maven Plugin
  2. Spring 4 MVC Ajax Hello World Example

上一篇: Intellij IDEA Auto reload a web application (hot deploy)
下一篇: Maven webxml attribute is required
 评论 ( What Do You Think )
名称
邮箱
网址
评论
验证
   
 

 


  • 微信公众号

  • 我的微信

站点声明:

1、一号门博客CMS,由Python, MySQL, Nginx, Wsgi 强力驱动

2、部分文章或者资源来源于互联网, 有时候很难判断是否侵权, 若有侵权, 请联系邮箱:summer@yihaomen.com, 同时欢迎大家注册用户,主动发布无版权争议的 文章/资源.

3、鄂ICP备14001754号-3, 鄂公网安备 42280202422812号