首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Maven-glassfish-plugin:如何指定部署目标?

Maven-glassfish-plugin:如何指定部署目标?
EN

Stack Overflow用户
提问于 2013-02-04 20:37:54
回答 2查看 3.6K关注 0票数 1

我正在使用maven3.0.4和Maven - Glassfish -plugin2.1 (http://maven-glassfish-plugin.java.net/)和Glassfish 2.1.1。

相关POM.XML分片:

代码语言:javascript
复制
<profile>
        <id>deploy</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.glassfish.maven.plugin</groupId>
                    <artifactId>maven-glassfish-plugin</artifactId>
                    <version>2.1</version>
                    <configuration>
                        <glassfishDirectory>/home/user/glassfish</glassfishDirectory>
                        <domain>
                            <name>domain1</name>
                            <host>hostname</host>
                            <adminPort>4848</adminPort>
                        </domain>
                        <autoCreate>false</autoCreate>
                        <terse>true</terse>
                        <debug>false</debug>
                        <echo>true</echo>
                        <user>admin</user>
                        <passwordFile>/home/user/user.gfpass</passwordFile>
                        <components>
                            <component>
                                <name>${project.artifactId}</name>
                                <artifact>${project.build.directory}/${project.build.finalName}.war</artifact>
                            </component>
                        </components>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>

问题是,我要部署到的Glassfish服务器为每个开发人员配置了一个独立实例,运行mvn glassfish:deploy会导致:

代码语言:javascript
复制
[INFO] --- maven-glassfish-plugin:2.1:deploy (default-cli) @ project ---
[INFO] deploy --port 4848 --enabled=true --host hostanme --precompilejsp=false --verify=false --echo=true --upload=true --terse=true --generatermistubs=false --passwordfile /home/user/user.gfpass --interactive=false --availabilityenabled=false --name project --target server --force=true --user admin /home/user/git/project/target/project-1.0.0-SNAPSHOT.war
[ERROR] CLI171 Command deploy failed : Application project is already deployed on other targets. Please remove all references or specify all targets (if not using asadmin command line) before attempting redeploy operation
[ERROR] Deployment of /home/user/git/project/target/project-1.0.0-SNAPSHOT.war failed.

请注意执行的命令中的--target server

如何在POM中指定要部署到哪个实例(即target)?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-02-05 15:36:07

经过进一步的研究,答案是不,我不能。

我知道有两种选择:

  1. 使用exec-maven-plugin使用所需的参数调用asadmin,或者使用
  2. Fork您自己的maven-glassfish-plugin版本并进行必要的更改(这就是我目前所做的)。

事实证明,这个插件非常简单,我可以毫不犹豫地修改它以满足我的需求。更麻烦的是构建它,但那是另一回事。

票数 2
EN

Stack Overflow用户

发布于 2015-01-18 02:38:05

你好,我的解决方案是:

我将pom留作重新部署执行。

代码语言:javascript
复制
        <execution>
                <id>gf-deploy</id>
                <phase>package</phase>
                <goals>
                    <goal>redeploy</goal>
                </goals>
            </execution>

然后我修改了asadmin.bat文件,在脚本调用appserver-cli.jar文件的行之后,我添加了3行新的行,注意redeploy调用了一个undeploy和一个部署命令,所以maven glassfish插件的诀窍是在undeploy命令运行时打印一些东西(Tihs会混淆maven插件,就好像undeploy命令总是成功的一样),但是,当asadmin命令是deploy时,流程将正常运行。

代码语言:javascript
复制
:run
if NOT %1 == undeploy goto :end
%JAVA% -jar "%~dp0..\lib\client\appserver-cli.jar" %*
ECHO "TEST"
:end

if %1 == undeploy goto :end1
%JAVA% -jar "%~dp0..\lib\client\appserver-cli.jar" %*
:end1

在做了这样的修改后,重复总是工作得很好!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14686973

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档