I have an SpringBoot app. with this service:
@Slf4j
@Service
public class AddressService {
private final RegionRepository regionRepository;
private final CommuneRepository communeRepository;
private final RestTemplate restTemplate;
public AddressService(RegionRepository regionRepository,
CommuneRepository communeRepository,
RestTemplate restTemplate) {
this.regionRepository = regionRepository;
this.communeRepository = communeRepository;
this.restTemplate = restTemplate;
}
public GeolocationAddress searchFromAddress(String address) {
// (..)
}
}
I have created this test:
@ExtendWith(SpringExtension.class)
@SpringBootTest
class AddressServiceTest {
@Autowired
AddressService addressService;
@Test
void searchFromAddress() {
System.out.println
(addressService.searchFromAddress("Plaza los Cubos)"));
}
}
But when I run the test I have this error:
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 2 of constructor in com.bonansa.service.AddressService required a bean of type 'org.springframework.web.client.RestTemplate' that could not be found.
Action:
Consider defining a bean of type 'org.springframework.web.client.RestTemplate' in your configuration.