当我使用wildfly maven插件将我的javaee应用程序部署到我的wildfly 8.1.0独立web应用程序服务器时,使用以下POM配置:
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>1.0.2.Final</version>
<configuration>
<hostname>127.0.0.1</hostname>
<port>9991</port>
<username>root</username>
<password>manager</password>
</configuration>
</plugin>
如果我运行mvn-wildfly:deploy,则应用程序已部署,并且我从服务器日志控制台收到以下消息:
....
21:45:42,100 INFO [org.jboss.as.server.deployment] (MSC service thread 1-8) JBAS015876: Starting deployment of "MyApp-0.0.1.war" (runtime-name: "MyApp-0.0.1.war")
21:45:42,819 INFO [org.wildfly.extension.undertow] (MSC service thread 1-7) JBAS017534: Registered web context: /MyApp-0.0.1
21:45:44,319 INFO [org.jboss.as.server] (management-handler-thread - 1) JBAS018562: Redeployed "MyApp-0.0.1.war"
....
如果我在POM插件的配置部分中指定名称参数,如下所示:
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>1.0.2.Final</version>
<configuration>
<hostname>127.0.0.1</hostname>
<port>9991</port>
<username>root</username>
<password>manager</password>
<name>WebApp</name>
</configuration>
</plugin>
应用程序已部署,但未指定Web上下文,如果我转到:http://127.0.0.1:8080/WebApp
,服务器将显示错误页面404!当使用此参数部署应用程序时,服务器控制台日志只显示以下消息:
....
21:44:28,299 INFO [org.jboss.as.repository] (management-handler-thread - 1) JBAS014900: Content added at location D:Wildflystandalonedatacontentc0e78f2599016bf33187b1049001b210040b829acontent
21:44:28,299 INFO [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015876: Starting deployment of "WebApp" (runtime-name: "WebApp")
21:44:28,705 INFO [org.jboss.as.server] (management-handler-thread - 1) JBAS018559: Redeployed "WebApp" (runtime-name : "WebApp")
....
为什么只有在名称规范的情况下,web上下文没有注册?我可以在配置参数(如应用程序名称)中指定web上下文吗?有人能帮我吗?
我已经尝试过了,结果发现你必须设置为WebApp.war才能让它工作。
我个人更喜欢使用标记直接在部分中设置名称,因为这更常见,并且可以省略文件扩展名。