8

単純なMavenベースのプロジェクトをmavenのようなリモートGlassFishサーバーにデプロイする方法について明確な答えが見つかりませんでした

mvn package xxx:deploy

GlassFish 3 をサポートするのは cargo プラグインだけだと思います。

構成側に問題があります。

サンプルのリモート GlassFish デプロイメントはどれもすばらしいものです。Cargo は必須ではありません。他がリモート GlassFish をサポートしている場合は、それも使用できます。

4

2 に答える 2

7

maven-glassfish-plugin (バージョン 2.1 など) のみを使用する場合は、"host" パラメーターを指定してリモート デプロイを実行できます。以下は、構成が maven settings.xml でセットアップされ、プラグインがプロファイルを使用してそれらをロードする例です。

settings.xml でプロファイルを定義します。

<profile>
     <id>production-config</id>    
     <properties>
       <glassfish.glassfishDirectory>/var/local/glassfish/</glassfish.glassfishDirectory>
       <glassfish.user>admin</glassfish.user>
       <glassfish.adminPassword>adminadmin</glassfish.adminPassword>
       <glassfish.domain.name>prd-domain</glassfish.domain.name>
       <glassfish.domain.host>NAMEOFYOURREMOTEHOST</glassfish.domain.host>
       <glassfish.domain.adminPort>10161</glassfish.domain.adminPort>
       .
       .
     </properties> 
</profile>

次に、このプロファイルをアクティブなプロファイルに入れます。

<activeProfiles>
    <activeProfile>production-config</activeProfile>
</activeProfiles>

Maven プロジェクト pom.xml でプロファイルを作成し、プロファイルのリストに maven-glassfish-plugin を追加します。

<profile>
    <id>production</id>
    <activation>
     <activeByDefault>false</activeByDefault>
     <os>
    <arch>x86</arch>
    <family>linux</family>
     </os>
     <property>
    <name>profile</name>
    <value>production</value>
     </property>
     <file>
      <exists>
       ${glassfish.glassfishDirectory}/domains/${glassfish.domain.name}/config/domain.passwords
      </exists>
     </file>
   </activation>
   <build>
      <plugins>
          <plugin>
               <groupId>org.glassfish.maven.plugin</groupId>
               <artifactId>maven-glassfish-plugin</artifactId>
               <configuration>
                  <terse>true</terse>
                  <echo>true</echo>
                  <debug>true</debug>
                  <glassfishDirectory>${glassfish.glassfishDirectory}</glassfishDirectory>
                  <user>${glassfish.user}</user>
                  <adminPassword>${glassfish.adminPassword}</adminPassword>
                  <domain>
                     <name>${glassfish.domain.name}</name>
                     <host>${glassfish.domain.host}</host>
                     <adminPort>${glassfish.domain.adminPort}</adminPort>
                  </domain>
                  <components>
                    <component>
                      <name>${project.artifactId}</name>  
                 <artifact>${project.build.directory}/${project.build.finalName}.war</artifact>
                    </component>
                  </components>
               </configuration>
               <executions>
                    <execution>
                <goals>
            <goal>deploy</goal>
            </goals>
            </execution>
        </executions>
         </plugin>
      </plugins>
    </build>
</profile>

これでうまくいくはずです。このプロファイルは、maven を使用して実行できます: mvn glassfish:deploy -P production または単にmvn deploy -P production (プラグインの実行部分内にゴール deploy を追加したため)

上記のモデルを使用すると、環境 (dev、acc、tst、prd) ごとに異なるプロファイルを作成し、異なる設定を使用できます。たとえば、ローカルのグラスフィッシュを使用してユニット/統合テストを展開および実行する開発者プロファイルを作成できます。

よくある間違いは、リモート展開を実行しているマシンの設定と、展開がインストールされるホストの設定を混同することです。glassfishDirectory は、デプロイ プラグインを実行している場所です。間違ったプラグインの結果、何もせずただ待っているだけで、何かが起こっているような印象を与えるだけです。もう 1 つの間違いは、リモート デプロイのパスワードの代わりにパスワード ファイルを指定することです。これも結果は何もありません。

于 2012-10-05T18:31:16.017 に答える
6

私の知る限り、Cargo だけが配信 (またはこの場合は展開) します。

これは、Maven OSGi WAR プロジェクトでの作業としてテストされた例です。

<build>
    <plugins> 
        ...
        <plugin>
            <groupId>org.codehaus.cargo</groupId>
            <artifactId>cargo-maven2-plugin</artifactId>
            <version>1.1.2</version>
            <configuration>
                <container>
                    <containerId>glassfish3x</containerId>
                    <type>remote</type>
                </container>
                <configuration>
                    <type>runtime</type>
                    <properties>
                        <cargo.hostname>myhostname</cargo.hostname>
                        <cargo.remote.username>myusername</cargo.remote.username>
                        <cargo.remote.password>mypassword</cargo.remote.password>
                    </properties>
                </configuration> 
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.glassfish.deployment</groupId>
                    <artifactId>deployment-client</artifactId>
                    <version>3.2-b06</version>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
</build>

ご覧のとおり、その秘訣はdeployment-client依存関係にあります。

完全を期すために、あなたmvn package cargo:deployとボブはあなたのおじです。

于 2011-09-23T17:26:52.060 に答える