Не найдено преобразователя, способного преобразовывать тип com.mongodb.BasicDBObject в тип org.springframework.security.oauth2.provider.OAuth2Authenticatio - PullRequest
0 голосов
/ 09 июля 2020

Я использую следующие и следующие библиотеки:

spring-boot: 1.5.4

spring-security - 3.2.7

spring-oauth: 2.0 .7

spring-boot-starter-data-mongodb: 1.5.4

spring-data-mongodb: 1.10.4

Когда я пытаюсь получить oauthtoken, используя этот POST url: http://localhost: 8080 / oauth / token? grant_type = password & username = abc & password = xyz & client_id = testing & client_secret = testing using postman Я получаю эту ошибку:

 {
"error": "server_error",
"error_description": "No converter found capable of converting from type [com.mongodb.BasicDBObject] to type [org.springframework.security.oauth2.provider.OAuth2Authentication]"
}

Пожалуйста, помогите

С уважением

Крис

1 Ответ

0 голосов
/ 13 июля 2020

Мне нужно предоставить преобразователь из DBObject в OAuth2Authentication, я сослался на эту ссылку Установить преобразователь MongoDb программно для программной регистрации преобразователей

MappingMongoConverter converter = new MappingMongoConverter(mongoDbFactory, context);
converter.setTypeMapper(mapper);
converter.setCustomConversions(new CustomConversions(
    Arrays.asList(
            new TimeZoneReadConverter(),
            new TimeZoneWriteConverter()
    )
 ));
converter.afterPropertiesSet();
MongoTemplate template = new MongoTemplate(mongoDbFactory, converter);

и эта ссылка Spring Отображение MongoDB OAuth2Authentication , которое преобразует DBObject в OAuth2Authentication, и я решил эту проблему.

С уважением

kris

...