我正在使用maven3.0.4和Maven - Glassfish -plugin2.1 (http://maven-glassfish-plugin.java.net/)和Glassfish 2.1.1。
相关POM.XML分片:
<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会导致:
[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)?
发布于 2013-02-05 15:36:07
经过进一步的研究,答案是不,我不能。
我知道有两种选择:
exec-maven-plugin使用所需的参数调用asadmin,或者使用maven-glassfish-plugin版本并进行必要的更改(这就是我目前所做的)。事实证明,这个插件非常简单,我可以毫不犹豫地修改它以满足我的需求。更麻烦的是构建它,但那是另一回事。
发布于 2015-01-18 02:38:05
你好,我的解决方案是:
我将pom留作重新部署执行。
<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时,流程将正常运行。
: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在做了这样的修改后,重复总是工作得很好!
https://stackoverflow.com/questions/14686973
复制相似问题