私はコレクションに別個の値を取得しようとしていました。 次のように私は時間を保存:mongodbの日付でJavaを使用しているクエリ
"time" : ISODate("2017-01-26T09:46:26.523Z")
new ISO8601DateFormat()
はエラー
org.bson.codecs.configuration.CodecConfigurationExceptionの下に私を与えることを、機能していません。 にクラス ためのコーデックを見つけることができませんcom.fasterxml.jackson.databind.util.ISO8601DateFormat。
私のコードは以下のようになります。
Query query = new Query();
query.addCriteria(Criteria.where("user_id").is(id).and("time").gt(new ISO8601DateFormat()));
mongoTemplate.getCollection("user_log").distinct("timezone", query.getQueryObject())
私のmongodb terminalコマンドは次のとおりです。完全に動作します。
db.user_log.find({ "user_id" : "1" , "time" : { "$gt" : new ISODate("2017-01-25T00:16:15.184Z")}})
私はjavaからアクセスするときに正しい方法はありますか?
たぶん役に立つリンクの下であなたの時間の基準を置き換えますhttp://stackoverflow.com/questions/30569228/mongodb-bson-codec-not-being-used-while -encoding-object – MateuszW90
あなたのJavaのバージョンは? – Veeram
@Veeram java 8 and spring boot –