title: Autowired interface null in spring boot
body: <p>Trying to build a services named AccountService an I don't know why my @Autowired field is null. I tried multiple things like ComponentScan and all the stuff you find on google.</p>
  <p>Thank you in advance :)</p>
  <p>The class that is being auto wired:</p>
  <pre><code>package de.scroll.AccountService.Account;
  
  import org.springframework.data.mongodb.repository.MongoRepository;
  import org.springframework.stereotype.Repository;
  
  import java.util.List;
  import java.util.Optional;
  
  @Repository
  public interface AccountRepository extends MongoRepository&lt;Account, String&gt; {
  
      public Optional&lt;Account&gt; findById(String id);
      public List&lt;Account&gt; findByEmailaddress(String email);
  }
  </code></pre>
  <p>The class in which the the auto wired class should be in use:</p>
  <pre><code>package de.scroll.AccountService;
  
  import de.scroll.AccountService.Account.AccountRepository;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
  
  @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class })
  public class AccountServiceApplication {
  
      @Autowired
      public static AccountRepository repository;
  
      public static void main(String[] args) {
          SpringApplication.run(AccountServiceApplication.class, args);
  
          test();
      }
  
      public static void test() {
          repository.findAll();
      }
  }
  </code></pre>
  <p>Error:</p>
  <pre><code>Exception in thread &quot;main&quot; java.lang.NullPointerException
      at de.scroll.AccountService.AccountServiceApplication.test(AccountServiceApplication.java:22)
      at de.scroll.AccountService.AccountServiceApplication.main(AccountServiceApplication.java:18)
  </code></pre>