使用maven-wildfly插件部署webapp,在部署目录下部署war

时间:2015-05-25 13:33:35

标签: java maven deployment wildfly-8

我正在使用wildfly-maven-plugin将webapp部署到 Wildfly 8.1 。使用wildfly:deploy目标,并将webapp部署在wildfly目录中的某个位置。以下是我的pom.xml和server.log。

<build>
        <plugins>             
            <plugin>
                <groupId>org.wildfly.plugins</groupId>
                <artifactId>wildfly-maven-plugin</artifactId>
                <version>1.0.2.Final</version> // Also tried latest one.
                <configuration>
                    <jbossHome>/home/me/jboss/</jbossHome>
                    <server-args>
                        <server-arg>-Djboss.server.base.dir=/home/me/jboss/standalone/</server-arg>
                        <server-arg>-b=0.0.0.0</server-arg>
                    </server-args>
                </configuration>
            </plugin>
        </plugins>
</build>

server.log

的一小部分
13:55:22,418 INFO  [org.jboss.as.server] (Controller Boot Thread) JBAS018559: Deployed "MyApp-1.0-SNAPSHOT.war" (runtime-name : "MyApp-1.0-SNAPSHOT.war")
13:55:22,671 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9990/management
13:55:22,672 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990
13:55:22,672 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: WildFly 8.1.0.Final "Kenny" started in 60324ms - Started 668 of 722 services (93 services are lazy, passive or on-demand)

但是我的/standalone/deployment/目录是空白的,也没有隐藏文件。所以这个东西部署的地方!!并且还从目标和.m2目录中删除了所有war文件。

standalone.xml

中的Webapp条目
<deployments>
    <deployment name="MyApp-1.0-SNAPSHOT.war" runtime-name="MyApp-1.0-SNAPSHOT.war">
            <content sha1="c9f1534c910dacdf6789ed585ae17cef73cfbe44"/>
    </deployment>
</deployments>

所以我需要在/standalone/deployments/目录下部署war文件。

2 个答案:

答案 0 :(得分:2)

Maven WildFly插件通过管理界面部署应用程序(默认情况下在端口9990上运行)。部署始终进入独立目录/ tmp。

部署到/ standalone / deployments /目录的替代方法是将应用程序战争直接复制到它。

答案 1 :(得分:0)

要在独立目录下部署您的应用程序,您需要将其复制到该路径。可以从 pom.xml 中进行配置,如下所示:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <executions>
        <execution>
            <id>copy-war</id>
            <phase>install</phase>
            <goals>
                <goal>copy</goal>
            </goals>
            <configuration>
                <artifactItems>
                    <artifactItem>
                        <groupId>${project.groupId}</groupId>
                        <artifactId>${project.artifactId}</artifactId>
                        <version>${project.version}</version>
                        <type>${project.packaging}</type>
                        <overWrite>true</overWrite>
                        <outputDirectory>\home\me\jboss\standalone\deployments</outputDirectory>
                        <destFileName>${project.build.finalName}.${project.packaging}</destFileName>
                    </artifactItem>
                </artifactItems>
            </configuration>
        </execution>
    </executions>
</plugin>