Я создал коллекцию как ниже
@Document(collection = "User")
public class User extends AbstractEntity{
private static final long serialVersionUID = 1L;
@NonNull
private String deviceId;
private GeoJsonPoint location;
public String getDeviceId() {
return deviceId;
}
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
public GeoJsonPoint getLocation() {
return location;
}
public void setLocation(GeoJsonPoint location) {
this.location = location;
}
}
и хранилище, как следует
public interface UserRepository extends MongoRepository<User, String> {
List<User> findAll();
User insert(User u);
}
, когда я добавляю нового пользователя с некоторым местоположением, как следует
User user1 = new User();
user1.setDeviceId("1010101010");
GeoJsonPoint locationPoint = new
GeoJsonPoint(53.10, 75.10);
user1.setLocation(locationPoint);
//user1.setLocation();
userRepository.save(user1);
Весна дает исключение, как следует
вызвано:
org.springframework.core.convert.ConverterNotFoundException: не найден конвертер, способный конвертировать данные из типа [org.springframework.data.mongodb.core.geo.GeoJsonPoint] в тип [org.bson.Document]
в org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound (GenericConversionService.java:321)
в org.springframework.core.convert.support.GenericConversionService.convert (GenericConversionService.java:194)
в org.springframework.core.convert.support.GenericConversionService.convert (GenericConversionService.java:174)
в org.springframework.data.mongodb.core.convert.MappingMongoConverter.getPotentiallyConvertedSimpleWrite (MappingMongoConverter.java:849)
в org.springframework.data.mongodb.core.convert.MappingMongoConverter.writeSimpleInternal (MappingMongoConverter.java:829)
в org.springframework.data.mongodb.core.convert.MappingMongoConverter.writeProperties (MappingMongoConverter.java:488)
в org.springframework.data.mongodb.core.convert.MappingMongoConverter.writeInternal (MappingMongoConverter.java:462)
в org.springframework.data.mongodb.core.convert.MappingMongoConverter.writeInternal (MappingMongoConverter.java:436)
в org.springframework.data.mongodb.core.convert.MappingMongoConverter.write (MappingMongoConverter.java:391)
в org.springframework.data.mongodb.core.convert.MappingMongoConverter.write (MappingMongoConverter.java:86)
в org.springframework.data.mongodb.core.MongoTemplate.toDocument (MongoTemplate.java:1070)
в org.springframework.data.mongodb.core.MongoTemplate.doInsert (MongoTemplate.java:1048)
в org.springframework.data.mongodb.core.MongoTemplate.insert (MongoTemplate.java:988)
в org.springframework.data.mongodb.repository.support.SimpleMongoRepository.save (SimpleMongoRepository.java:80)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (собственный метод)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
в java.lang.reflect.Method.invoke (Method.java:498)
в org.springframework.data.repository.core.support.RepositoryComposition $ RepositoryFragments.invoke (RepositoryComposition.java:377)
в org.springframework.data.repository.core.support.RepositoryComposition.invoke (RepositoryComposition.java:200)
в org.springframework.data.repository.core.support.RepositoryFactorySupport $ ImplementMethodExecutionInterceptor.invoke (RepositoryFactorySupport.java:629)
в org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (ReflectiveMethodInvocation.java:185)
в org.springframework.data.repository.core.support.RepositoryFactorySupport $ QueryExecutorMethodInterceptor.doInvoke (RepositoryFactorySupport.java:593)
в org.springframework.data.repository.core.support.RepositoryFactorySupport $ QueryExecutorMethodInterceptor.invoke (RepositoryFactorySupport.java:578)
в org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (ReflectiveMethodInvocation.java:185)
в org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke (DefaultMethodInvokingMethodInterceptor.java:59)
в org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (ReflectiveMethodInvocation.java:185)
в org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke (ExposeInvocationInterceptor.java:92)
в org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (ReflectiveMethodInvocation.java:185)
в org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke (SurroundingTransactionDetectorMethodInterceptor.java:61)в org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (ReflectiveMethodInvocation.java:185)
в org.springframework.aop.framework.JdkDynamicAopProxy.invoke (JdkDynamicAopProxy.java:212)
на com.sun.proxy. $ Proxy127.save (неизвестный источник)
на com.gt.ffm.restful.Application.run (Application.java:94)
в org.springframework.boot.SpringApplication.callRunner (SpringApplication.java:797)
... еще 11