How to AutoWire spring beans when using Mockito and Junit?
<p>I am trying to set up my  class to be used in <code>Junit</code>.</p>

<p>However when I try to do the below I get an error. </p>

<p><strong>Current Test Class:</strong></p>

<pre><code>public class PersonServiceTest {

    @Autowired
    @InjectMocks
    PersonService personService;

    @Before
    public void setUp() throws Exception
    {
        MockitoAnnotations.initMocks(this);
        assertThat(PersonService, notNullValue());

    }

    //tests
</code></pre>

<p><strong>Error:</strong></p>

<pre><code>org.mockito.exceptions.base.MockitoException: 
Cannot instantiate @InjectMocks field named 'personService'
You haven't provided the instance at field declaration so I tried to construct the instance.
However the constructor or the initialization block threw an exception : null
</code></pre>

<p>How can I fix this?</p>