title: Spring Injecting Beans from src folder in test folders
body: <p>I have utility classes exposed as beans in my source folders. I want to use some of those utilities in my test classes written in junit 4. For example , I have a utility class that has methods which marshal an object into JSON string. I want to inject this utility bean in my test class. I am unable to inject these beans using Autowired annotation. Should I copy all these classes over to test folder?</p>
  
  <p>Edit:</p>
  
  <p>I am trying to inject jsonUtil. Below is how my code looks like.</p>
  
  <pre><code>import static org.junit.Assert.*;
  
  import java.math.BigDecimal;
  
  @RunWith(MockitoJUnitRunner.class)
  @SpringApplicationConfiguration(classes = ProxyApplicationMock.class)
  public class ProxyApplicationMock {
  
      @Mock
      public SoapClient soapClientMock;
  
      private JsonUtil jsonUtil;
  </code></pre>
  
  <p>Main Class</p>
  
  <pre><code>public class ProxyApplication {
  
      public static void main(String[] args) {
          SpringApplication.run(ProxyApplication.class, args);
      }
  }
  </code></pre>