Eclipse Mars 清理构建并将 war 移动到 Jboss 部署目录

Eclipse Mars clean build and move war to Jboss deployment directory

我正在使用带有 Maven 集成插件的 Eclipse Mars,并在 Eclipse Mars 中配置 JBoss EAP 7.0 服务器。

我按照maven构建配置guide在目标目录成功构建生成war。

是否可能,使用 maven build 运行 > "clean install" 在目标目录中创建一个新的 project.war。同时,project.war 将上传到 %JBOSS_HOME%\standalone\deployments 目录。我尝试同时绑定构建和导出过程。

我尝试在 pom.xml 中添加以下配置但没有用。

<configuration>
    ....
    <webappDirectory>D:\jboss-eap-7.0.0\jboss-eap-7.0\standalone\deployments\</webappDirectory>
</configuration>

<configuration>
    ....
    <outputDirectoryD:\jboss-eap-7.0.0\jboss-eap-7.0\standalone\deployments\</outputDirectory>
</configuration>

<executions>
    <execution>
        <phase>install</phase>
        <configuration>
            <target>
               <copy file="D:\workspace\project\target\project.war"
                                    todir="D:\jboss-eap-7.0.0\jboss-eap-7.0\standalone\deployments\" />
            </target>
        </configuration>
        <goals>
            <goal>run</goal>
        </goals>
    </execution>
</executions>

结果:

[ERROR] Could not find goal 'run' in plugin org.apache.maven.plugins:maven-compiler-plugin:3.1 among available goals testCompile, compile, help -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoNotFoundException

经过几次尝试,我决定使用替代解决方案。 我需要什么基本上编译一个 war 文件并部署到 Jboss 服务器。

我编写了一个如下的批处理作业来实现相同的目标。 在我从 Eclipse 更改源代码后,我将 运行 这个批处理作业来触发更改。

批处理作业

SET WORKSPACE=D:\workspace\project\
SET JBOSS_DEPLOYMENT=D:\jboss-eap-7.0.0\jboss-eap-7.0\standalone\deployments\

cd /D %WORKSPACE%
echo %WORKSPACE%

call mvn clean package

xcopy /y %WORKSPACE%\target\*.war %JBOSS_DEPLOYMENT%

echo Move war from %WORKSPACE% to %JBOSS_DEPLOYMENT%

pause

这个批处理作业会编译新的war文件并复制war到JBoss部署目录,如果服务器检测到war有任何更新会自动热部署.