Red Hat Training

A Red Hat training course is available for Red Hat JBoss Data Virtualization

4.3. オンラインリポジトリーを使用するよう Maven を設定

Red Hat JBoss Data Virtualization に必要なオンラインリポジトリーは http://maven.repository.redhat.com/techpreview/all/ にあります。
インストール中に Maven の settings.xml ファイルの場所を指定した場合、Maven はすでにオンラインリポジトリーを使用するよう設定されています。
インストール中に Maven リポジトリーを設定しなかった場合、以下の手順に従ってリポジトリーを設定することができます (プロジェクトの POM ファイルを使用して設定することもできますが、推奨されません)。

手順4.2 オンラインリポジトリーを使用するよう Maven を設定

  1. 以下のコードサンプルのように、オンラインリポジトリーのエントリーを Maven の settings.xml ファイルに追加します。
    <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" 
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
    
      <profiles>
        <!-- Profile with online repositories required by Data Virtualization -->
        <profile>
          <id>dv-online-profile</id>
          <repositories>
            <repository>
              <id>jboss-ga-repository</id>
              <url>http://maven.repository.redhat.com/techpreview/all</url>
              <releases>
                <enabled>true</enabled>
              </releases>
              <snapshots>
                <enabled>false</enabled>
              </snapshots>
            </repository>
          </repositories>
          <pluginRepositories>
            <pluginRepository>
              <id>jboss-ga-plugin-repository</id>
              <url>http://maven.repository.redhat.com/techpreview/all</url>
              <releases>
                <enabled>true</enabled>
              </releases>
              <snapshots>
                <enabled>false</enabled>
              </snapshots>
            </pluginRepository>
            
          </pluginRepositories>
        </profile>    
      </profiles>
    
      <activeProfiles>
        <!-- Activation of the Data Virtualization profile -->
        <activeProfile>dv-online-profile</activeProfile>
      </activeProfiles>
    
    </settings>
  2. JBoss Developer Studio の稼働中に settings.xml ファイルを変更した場合は、IDE の Maven 設定を更新する必要があります。メニューで WindowPreferences と選択します。 Preferences ウインドウで Maven を展開し、User Settings を選択します。Update Settings ボタンをクリックし、JBoss Developer Studio の Maven ユーザー設定を更新します。
    Maven ユーザー設定の更新

    図4.2 Maven ユーザー設定の更新

結果:

Red Hat JBoss 製品向けに提供されるオンラインリポジトリーを使用するよう Maven が設定されます。

重要

キャッシュされたローカル Maven リポジトリーに古いアーティファクトが含まれる場合は、プロジェクトをビルドまたはデプロイしたときに以下のいずれかの Maven エラーメッセージが発生することがあります。
  • Missing artifact ARTIFACT_NAME
  • [ERROR] Failed to execute goal on project PROJECT_NAME; Could not resolve dependencies for PROJECT_NAME
この問題を解決するには、キャッシュされたローカルディレクトリーを削除します。このディレクトリーは Linux の場合は ~/.m2/repository/ ディレクトリー、Windows の場合は %SystemDrive%\Users\USERNAME\.m2\repository\ ディレクトリーになります。これにより、次回の構築中に Maven が必要なアーティファクトの適切なバージョンをダウンロードするようになります。