maven-glassfish-plugin使用

来源:互联网 发布:淘宝退货的联系电话 编辑:程序博客网 时间:2024/06/05 10:41

以前曾经用过一阵子maven-glassfish-plugin,后来有一阵子突然不能访问公共仓库(GFW干的),导致放弃了这种用法。

现在依赖公司Nexus私服,又尝试了一次。


首先添加如下配置到pom.xml中

      <!-- This plugin is only used for developer to deploy war on local glassfish-->      <plugin><groupId>org.glassfish.maven.plugin</groupId><artifactId>maven-glassfish-plugin</artifactId><version>2.1</version><configuration>  <glassfishDirectory>/home/chenshu/glassfish-3.1.2</glassfishDirectory>  <user>admin</user>  <passwordFile>pwd</passwordFile>  <autoCreate>true</autoCreate>  <debug>true</debug>  <echo>true</echo>  <terse>true</terse>  <domain>    <name>domain1</name>    <adminPort>4848</adminPort>    <httpPort>8080</httpPort>    <httpsPort>8443</httpsPort>    <iiopPort>3700</iiopPort>    <jmsPort>7676</jmsPort>    <reuse>false</reuse>  </domain>  <components>            <component>              <name>${project.artifactId}</name>              <artifact>${project.build.directory}/${project.build.finalName}.war              </artifact>            </component>          </components></configuration>      </plugin>


运行mvn glassfish:deploy后

出现了错误:

[ERROR] Failed to execute goal org.glassfish.maven.plugin:maven-glassfish-plugin:2.1:deploy (default-cli) on project geoflow: Execution default-cli of goal org.glassfish.maven.plugin:maven-glassfish-plugin:2.1:deploy failed: Plugin org.glassfish.maven.plugin:maven-glassfish-plugin:2.1 or one of its dependencies could not be resolved: Failed to collect dependencies for org.glassfish.maven.plugin:maven-glassfish-plugin:jar:2.1 (): Failed to read artifact descriptor for org.apache.maven:maven-plugin-api:jar:2.1.0-M2-SNAPSHOT: Could not find artifact org.apache.maven:maven-parent:pom:11-SNAPSHOT in nexus (http://turtleship:8080/nexus/content/groups/public) -> [Help 1]
说依赖的maven-plugin-api 2.1.0-M2-SNAPSHOT找不到artifact(也就是找不到jar包).原来是私服惹的祸。

登陆Nexus,然后从公共仓库中删除Apache-snapshot仓库。再运行一次,好了。


注意,开发用的GlassFish为了节省时间是通过NetBeans7.1.2安装的时候一起安装的。这个开发版本的GlassFish3.1.2用户名是admin,密码是空,因此需要先在项目目录下创建一个空文件pwd. 如果空文件不行,就添加一行:

AS_ADMIN_PASSWORD=


注意,由于asadmin命令行不支持--contextroot参数,因此maven-glassfish-plugin也不能修改contextroot的值,只能通过sun-web.xml中指定。



原创粉丝点击