【问题标题】:How to deploy a Maven web application to a local-installed Glassfish?如何将 Maven Web 应用程序部署到本地安装的 Glassfish?
【发布时间】:2017-02-16 11:48:13
【问题描述】:

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

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

【问题讨论】:

    标签: maven deployment glassfish


    【解决方案1】:

    是的,可以使用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>
    

    使用上面引用的插件部署的 maven 命令是:

    mvn clean package cargo:deploy
    

    clean package cargo:redeploy
    

    【讨论】:

      【解决方案2】:

      您需要指定插件的版本。 Maven 版本 3 给了我一些关于这个问题的警告。

      【讨论】:

        【解决方案3】:

        我遇到了类似的问题,使用 Glassfish 的 asadmin 进行部署。

        我刚刚通过使用您提到的 Maven 插件将此插件添加到我的POM.xml 找到了问题的解决方案(链接:https://alexjoz.gitbooks.io/code-life/content/chapter3.html

        <plugin>
            <groupId>org.glassfish.maven.plugin</groupId>
            <artifactId>maven-glassfish-plugin</artifactId>
            <version>2.1</version>
            <configuration>
            <glassfishDirectory>D:\\Users\\admin\\GlassFish_Server_5.1.0\\glassfish</glassfishDirectory>
                <user>admin</user>
                <passwordFile>D:\\Users\\admin\\GlassFish_Server_5.1.0\\glassfish\\domains\\domain1\\config\\domain-passwords</passwordFile>
                <domain>
                    <name>domain1</name>
                    <httpPort>8080</httpPort>
                    <adminPort>4848</adminPort>
                </domain>
                <components>
                    <component>
                        <name>${project.artifactId}</name>
                        <artifact>target/${project.artifactId}-${project.version}.war</artifact>
                    </component>
                </components>
                <debug>true</debug>
                <terse>false</terse>
                <echo>true</echo>
            </configuration>
        </plugin>
        

        然后我只是点击了运行,等待 JSP 页面出现。

        我的项目信息:

        • Netbeans 12
        • jdk 1.8
        • Glassfish 5.1.0
        • Spring MVC 框架 5.2.2.RELEASE

        【讨论】:

          猜你喜欢
          • 2016-02-16
          • 1970-01-01
          • 2015-05-20
          • 2013-05-26
          • 1970-01-01
          • 2013-04-15
          • 2018-03-13
          • 2015-10-17
          • 2012-08-12
          相关资源
          最近更新 更多