SaiUpadhyayula / spring-boot-microservices

This repository contains the latest source code of th spring-boot-microservices tutorial

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

@Autowired ObjectMapper Issue

samreiss opened this issue · comments

@SaiUpadhyayula Awesome Tutorial / Example. Thank you!

FYI - When I run the tests in ProductServiceApplicationTests, the following line autowire is problematic. I can create an instance of the objectMapper inside of the tests and they work, but I don't seem to be able to use @Autowired.

@Autowired
private  ObjectMapper objectMapper;

Here's the error that I receive when using @Autowired.

Unsatisfied dependency expressed through field 'objectMapper': No qualifying bean of type 'org.testcontainers.shaded.com.fasterxml.jackson.databind.ObjectMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

Hi, you are using Object Mapper from wrong library

org.testcontainers.shaded.com.fasterxml.jackson.databind.ObjectMapper

Make sure you are using only the class from Jackson library