<!-- Define the Mockito class as factory for creating the mock -->
<bean id="restTemplate" class="org.mockito.Mockito" factory-method="mock">
<!-- The constructor contains the full name of the class being mocked -->
<constructor-arg value="org.springframework.web.client.RestTemplate"/>
</bean>
The defined restTemplate bean can be be referenced in other bean definitions, for instance the object under test.