6

Cargo は従属 Maven モジュールから WAR を問題なく実行するため、Maven の jetty プラグインから Cargo プラグイン (cargo-maven2-plugin) に移行しています。Web アプリ内では、JNDI を介してすべての構成を外部化するために多大な労力を費やしました。これらの JNDI 定義は Web アプリ固有であるため、WAR の外部にある jetty-env.xml ファイルに配置されます。Jetty プラグインを使用して、このファイルを次のように指定しました。

        <plugin>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>maven-jetty-plugin</artifactId>
            <configuration>
                <jettyEnvXml>${basedir}/target/config/jetty-env.xml</jettyEnvXml>
            </configuration>
        </plugin>

Cargo プラグイン内でこれを指定するにはどうすればよいですか? これが私がこれまでに持っている構成です。もちろん、JNDI 構成がないために失敗します。

        <plugin>
                <groupId>org.codehaus.cargo</groupId>
                <artifactId>cargo-maven2-plugin</artifactId>
                <configuration>
                    <container>
                        <containerId>jetty6x</containerId>
                        <type>embedded</type>
                    </container>
                    <configuration>
                        <deployables>
                            <deployable>
                                <groupId>com.mycompany</groupId>
                                <artifactId>my-war-module</artifactId>
                                <type>war</type>
                                <properties>
                                   <context>/</context>
                                </properties>
                            </deployable>
                        </deployables>
                    </configuration>
                    <wait>false</wait>
                </configuration>
                <executions>
                           ......
                </executions>
        </plugin>
4

4 に答える 4

3

CARGO-804によると、Cargo の Jetty デプロイヤは、war 内への jetty-env.xml の埋め込みをサポートするようになりました (バージョン 1.0.3 以降)。

そして、あなたの「本当の」戦争の外を保つためにjetty-env.xml、私の提案は、jetty-env.xmlファイルをホストする追加の戦争モジュールを作成し、CARGO を構成してWAR ファイルをマージすることです ( CARGO<extensions>true</extensions>で述べたように、重要な要素に特別な注意を払います) -524)。

于 2010-10-28T05:00:23.227 に答える
1

私は同じ問題を共有しており、クリーンインストールを希望しています。私は WAR ファイルのマージに魅力を感じませんでした。代わりに、アセンブリを使用して、すべての外部プロパティの ZIP ファイルを維持しています。個別のモジュールとして、ZIP ファイルの内容を JETTY 環境にデプロイできます。次に、Jetty が Web アプリの名前を使用して無料の環境ファイルをロードする方法を利用します (webapps/foo.war の場合、Jetty は構成に contexts/foo.xml を使用します)。したがって、純粋な Cargo ソリューションほどコンパクトではありませんが、プロモーション プロセス全体で WAR ファイルの進行が純粋であるため、私はそれを好みます。このソリューションは、すべての構成アクティビティを管理するための一般的なメカニズムでもあります。誰かが興味を持っている場合は、詳細を指摘できます。

于 2010-12-06T23:31:35.080 に答える
1

Mond の回答は、Cargo の構成を使用して (名前を変更し、わずかに変更した) jetty-env.xml を "contexts" ディレクトリに保存できるのではないかという考えに火をつけました。驚いたことに、それはうまくいきました。ここで私がしたこと:

私の貨物構成に、次を追加しました。

<configfiles>  
  <configfile>  
      <file>${basedir}/../config/jetty-env.xml</file>
    <todir>contexts</todir>
     <tofile>${jetty6.context}.xml</tofile>
   </configfile>
</configfiles>

しかし、jetty-env.xml を実際の context.xml に変えるために、以下を追加しました。

<!-- Activates the Jetty-Plus feature so we can create/share JNDI resources -->
<Array id="plusConfig" type="java.lang.String">
    <Item>org.mortbay.jetty.webapp.WebInfConfiguration</Item>
    <Item>org.mortbay.jetty.plus.webapp.EnvConfiguration</Item>
    <Item>org.mortbay.jetty.plus.webapp.Configuration</Item>
    <Item>org.mortbay.jetty.webapp.JettyWebXmlConfiguration</Item>
    <Item>org.mortbay.jetty.webapp.TagLibConfiguration</Item>
</Array>

<!-- Miscellaneous properties that were take from the CARGO version of this file that is created automatically
    (and then replaced by this file). If you ever upgrade Cargo you may need to change these. -->
<Set name="contextPath">/${jetty6.context}</Set>
<Set name="war">
    <SystemProperty name="config.home" default="."/>/webapps/${jetty6.context}.war</Set>
<Set name="extractWAR">true</Set>
<Set name="defaultsDescriptor">
    <SystemProperty name="config.home" default="."/>/etc/webdefault.xml</Set>
<Set name="ConfigurationClasses">
    <Ref id="plusConfig" />
</Set>

CARGO が自分のコンテキスト ファイルをそこにコピーした後でダンプするのではないかと心配していましたが、最後にコピーしたのは賢明でした。

于 2010-12-11T04:42:47.550 に答える
1

私がやりたいことは、プロパティをフィルタリングすることです。これまでのところ、私はこれを持っています:

    <profile>
        <id>deploy-properties</id>
        <activation>
            <activeByDefault>false</activeByDefault>
        </activation>
        <properties>
            <deployable.classifier>properties</deployable.classifier>
            <deployable.type>zip</deployable.type>
            <ys.imq.user>UserFromDeploymentPom</ys.imq.user>
            <ys.imq.password>PasswordFromDeploymentPom</ys.imq.password>
        </properties>
        <dependencies>
            <dependency>
                <groupId>${project.groupId}</groupId>
                <artifactId>${deployable.artifactId}</artifactId>
                <classifier>${deployable.classifier}</classifier>
                <type>${deployable.type}</type>
                <version>${project.version}</version>
            </dependency>
        </dependencies>
        <build>
            <plugins>
                <plugin>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <executions>
                        <execution>
                            <phase>process-resources</phase>
                            <goals>
                                <goal>unpack</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <artifactItems>
                            <artifactItem>
                                <groupId>${project.groupId}</groupId>
                                <artifactId>${deployable.artifactId}</artifactId>
                                <classifier>${deployable.classifier}</classifier>
                                <version>${project.version}</version>
                                <type>${deployable.type}</type>
                                <overWrite>true</overWrite>
                                <outputDirectory>/tmp/${deployable.artifactId}</outputDirectory>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </plugin>
                <plugin>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>2.4.3</version>
                    <executions>
                        <execution>
                            <id>copy-resources</id>
                            <phase>package</phase>
                            <goals>
                                <goal>copy-resources</goal>
                            </goals>
                            <configuration>
                                <outputDirectory>${deploy.jettyHome}</outputDirectory>
                                <overwrite>true</overwrite>
                                <resources>
                                    <resource>
                                        <directory>/tmp/${deployable.artifactId}</directory>
                                        <filtering>true</filtering>
                                    </resource>
                                </resources>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>

私が好むよりも少し複雑ですが、Jetty に追加しながらプロパティをフィルタリングすることができます。これにより、システム プロパティを使用して、パスワードやその他の機密データを上書きできます。私たちは Bamboo を使用しており (Hudson も同様だと思います)、環境ごとに計画を調整できます。プランはアクセス制御の対象となる場合があります。これにより、すべての展開プロパティを 1 か所で設定できるため、管理者が Unix ボックスをハッキングする必要がなくなります。

于 2010-12-13T23:36:22.623 に答える