私は3つのMavenモジュールを持っています:
- Dao (DAO インターフェイスを含む)、
- DaoImpl (Dao を実装する DAO クラスを含む)、
- サービス (DaoImpl オブジェクトを使用するサービスを含む)。
3 つのモジュール間の依存関係は次のようになります。
DaoImpl -> Dao <- サービス
「->」は「依存」を意味します
DaoImpl Bean を Service Bean に注入したいと思います。問題は Service が DaoImpl に依存していないため、そのクラスパスにアクセスできないことです。したがって、Service で宣言された DaoImpl Bean は、DaoImpl のアプリケーション コンテキストで宣言された Bean にオートワイヤーできません。
1 つの解決策は、Service を DaoImpl に依存させることです。
Dao <- DaoImpl <- サービス
しかし、このケースでは、DAO 用のインターフェイスを持つ意味はありません。モジュール Dao は不要になり、DaoImpl が公開されます。
この主題について何か議論はありますか?
よろしくお願いします。