如何将 Maven Web 应用程序部署到本地安装的 Glassfish?

Jac*_*iro 5 deployment glassfish maven

如何仅使用 Maven 插件将 Maven Web 应用程序部署到本地安装的 glassfish 服务器?

换句话说,如果我有一个带有 Packaging=war 的 Maven 项目,可以使用“mvn clean package some-plugin:goal-deploy”之类的命令部署到本地安装的 glassfish 吗?

Jac*_*iro 7

是的,可以使用Cargo Maven Plugin,因为它在以下示例中进行了自我解释:

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.cargo</groupId>
            <artifactId>cargo-maven2-plugin</artifactId>
            <configuration>
                <container>
                    <containerId>glassfish4x</containerId>
                    <type>installed</type>
                    <!-- Path to directory where glassfish is installed -->
                    <home>C:/programs/glassfish4</home>
                </container>
                <configuration>
                    <type>existing</type>
                    <!-- Path to domains directory -->
                    <home>C:/programs/glassfish4/glassfish/domains</home>
                    <properties>
                        <!-- Domain name where application will be deployed. -->
                        <cargo.glassfish.domain.name>domain1</cargo.glassfish.domain.name>
                        <!-- Glassfish user to authenticate -->
                        <cargo.remote.username>admin</cargo.remote.username>
                        <!-- Glassfish password to authenticate -->
                        <cargo.remote.password></cargo.remote.password>
                    </properties>
                </configuration>
            </configuration>
        </plugin>
    </plugins>
</build>
Run Code Online (Sandbox Code Playgroud)

使用上面引用的插件进行部署的 Maven 命令是:

mvn clean package cargo:deploy
Run Code Online (Sandbox Code Playgroud)

或者

clean package cargo:redeploy
Run Code Online (Sandbox Code Playgroud)