Wildfly Maven插件关闭并启动现有服务器

时间:2016-12-06 20:01:42

标签: maven wildfly

如何配置wildfly maven插件来关闭并启动现有的wildfly实例?它正在下载服务器文件,然后启动服务器。另一个问题是清洁正确的使用阶段?我想要的是能够只需要一次点击就可以重新部署并重新启动服务器。

我的pom.xml文件中有以下内容。

<plugin>
    <groupId>org.wildfly.plugins</groupId>
    <artifactId>wildfly-maven-plugin</artifactId>
    <version>1.1.0.Alpha11</version>
    <configuration>
        <force>true</force>
        <hostname>${jboss-as.deploy.hostname}</hostname>
        <username>${jboss-as.deploy.user}</username>
        <password>${jboss-as.deploy.pass.prod}</password>
        <fileNames>
             <fileName>target/${plugin.war.warName}.war</fileName>
        </fileNames>
     </configuration>
     <executions>
        <execution>
            <id>undeploy</id>
            <phase>clean</phase>
            <goals>
               <goal>undeploy</goal>
            </goals>
        </execution>
        <execution>
            <id>deploy</id>
            <phase>clean</phase>
            <goals>
                <goal>deploy</goal>
            </goals>
        </execution>
        <execution>
            <id>shutdown</id>
            <phase>clean</phase>
            <goals>
                <goal>shutdown</goal>
            </goals>
        </execution>
        <execution>
            <id>start</id>
            <phase>clean</phase>
            <goals>
                <goal>start</goal>
            </goals>
        </execution>
    </executions>
</plugin>

2 个答案:

答案 0 :(得分:1)

在开始目标上,您只需指定<jboss-home/>即可。这将启动位于指定路径中的服务器。

这取决于您绑定到哪个阶段的用例。确实没有正确或错误的答案。但是,deploy目标确实需要执行package阶段。

另一个可能的问题是在执行start目标之前服务器可能没有完全关闭。执行shutdown后跟start目标是一种竞争条件。

答案 1 :(得分:0)

我今天花了很多时间来解决这个问题。这是我的解决方案,如果它仍然适用于任何人:

<execution>
    <id>deploy</id>
    <phase>pre-integration-test</phase>
    <configuration>
        <jboss-home>/path/to/wildfly</jboss-home>
    </configuration>
    <goals>
        <goal>start</goal>
        <goal>deploy</goal>
    </goals>
    </execution>

    <execution>
    <id>cleanup</id>
        <phase>post-integration-test</phase>
        <goals>
            <goal>undeploy</goal>
        </goals>
    </execution>

所以,这里发生的事情是我们启动服务器并在一个步骤中部署应用程序&#39; (生命周期阶段,更具体)。然后在测试运行后,取消部署应用程序。 wildfly插件很聪明,可以确定它应该自己关闭服务器。我的wildfly插件版本是1.1.0.Alpha5

此外,当我尝试在不同的阶段启动和部署时,服务器启动了两次并出于某种原因引发了各种问题。

我认为这是最干净的解决方案,除非您特别希望服务器在测试之间进行。