定義したいくつかのルールに基づいて、SpEL を使用して同じドキュメントを別のコレクションにロードしようとしています。
だから私が持っているものから始める:
-まず最初にドキュメント:
@Document(collection = "#{@mySpecialProvider.getTargetCollectionName()}")
public class MongoDocument {
// some random fields go in
}
-second コレクション名を提供するプロバイダー Bean があります。
@Component("mySpecialProvider")
public class MySpecialProvider {
public String getTargetCollectionName() {
// Thread local magic goes in bellow
String targetCollectionName = (String) RequestLocalContext.getFromLocalContext("targetCollectionName");
if (targetCollectionName == null) {
targetCollectionName = "defaultCollection";
}
return targetCollectionName;
}
}
問題は、プロバイダーによって生成される特定のコレクションにドキュメントを挿入しようとすると、次のスタック トレースが表示されることです。
org.springframework.expression.spel.SpelEvaluationException: EL1057E:(pos 1): Bean 'mySpecialProvider' へのアクセスを解決するコンテキストに Bean リゾルバーが登録されていません
また、春のコンポーネントApplicationContextAwareを作成しようとしましたが、まだ運がありません。