Home > database >  Java location query GeoJsonPoint Codec or PojoCodec
Java location query GeoJsonPoint Codec or PojoCodec

Time:10-29

Be successful insertion,

Query the error

Always find a public constructor for 'GeoJsonPoint. \ r \ n \ r \ nA custom Codec or PojoCodec may need to be explicitly configured and registered to handle this type.


Has joined the GeoJsonCodecProvider when access to the database

 
Public static MongoDatabase getDatabase () {
The ConnectionString connString=new ConnectionString (conn);
MongoClientSettings Settings=MongoClientSettings. Builder ()
. ApplyConnectionString (connString)
RetryWrites (true)
.build();
CodecRegistry cr=fromProviders (PojoCodecProvider. Builder (). Automatic (true). The build (),
New ValueCodecProvider (),
New BsonValueCodecProvider (),
New DBRefCodecProvider (),
New DBObjectCodecProvider (),
New DocumentCodecProvider (new DocumentToDBRefTransformer ()),
New IterableCodecProvider (new DocumentToDBRefTransformer ()),
New MapCodecProvider (new DocumentToDBRefTransformer ()),
New GeoJsonCodecProvider (),
New GridFSFileCodecProvider ());

MongoClient MongoClient=MongoClients. Create (Settings);
Return mongoClient. GetDatabase (" test "). WithCodecRegistry (cr);
};


CodePudding user response:

https://stackoverflow.com/questions/48088738/spring-requestbody-with-geojsonpoint

His find a temporary solution is to write a same class...

While it is possible to solve the problem but the feeling is not the optimal solutions for the future
  • Related