MySQL ドライバーの依存関係

AEM as a Cloud Service では、多くの場合、接続をサポートするために Java™ データベースドライバーを提供する必要があります。 ドライバーの提供は、通常、これらのドライバーを含む OSGi バンドルアーティファクトを all パッケージ経由で AEM プロジェクトに埋め込むことで達成します。

pom.xml のリファクタリング

データベースドライバの依存関係をリアクター pom.xml に含め、all サブプロジェクトで参照します。

  • pom.xml
...
<dependencies>
    ...
    <!-- MySQL Driver dependencies -->
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>[8.0.27,)</version>
        <scope>provided</scope>
    </dependency>
    ...
</dependencies>
...

すべての pom.xml

データベースドライバーの依存関係アーティファクトを all パッケージをAEM as a Cloud Service上にデプロイして使用できるようにします。これらのアーティファクトは​ 必須 ​データベースドライバー Java™ クラスを書き出す OSGi バンドルである必要があります。

  • all/pom.xml
...
<embededs>
    ...
    <!-- Include the MySQL Driver OSGi bundles for deployment to the project -->
    <embedded>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <target>/apps/wknd-examples-vendor-packages/application/install</target>
    </embedded>
    ...
</embededs>

...

<dependencies>
    ...
    <!-- Add MySQL OSGi bundle artifacts so the <embeddeds> can add them to the project -->
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <scope>provided</scope>
    </dependency>
    ...
</dependencies>
...
recommendation-more-help