title: spring boot Cannot invoke Repository because Repository is null
body: <pre><code>public class UserList {
  
      private  String id;
      private String email;
      private String userType;
      private String rolls;
      private String partner;
      private Integer customersLinked;
      private String position;
      private String status;
  
      @Autowired
      ICustomerRepository customerRepository;
  
      public UserList (Users user){
          this.id = user.getId();
          this.email = user.getEmail();
          this.userType = user.getUserType();
          this.rolls = user.getRolls();
          this.partner = user.getPartner();
  
         List&lt;Customer&gt; customersLinked = customerRepository.findAllByLinkedUsersIn(user.getId());
          this.customersLinked = 0;
          this.position = user.getPosition();
          this.status =user.getStatus();
      }
  
      //Getter and Setter
  }
  </code></pre>
  <p>This class is used as a list in the frontEnd ,get specific data ,not send all the data</p>
  <pre><code> @RequestMapping(value = &quot;usersLinked/{id}/{type}&quot;, method = RequestMethod.GET)
      public Object getUsersLinkedById(@PathVariable(&quot;id&quot;) String id,@PathVariable(&quot;type&quot;) Integer type) {
          List&lt;String&gt; users = null;
          switch (type) {
              case 0:
                  users = usersRepository.findAll().stream().map(m -&gt; m.getId()).collect(Collectors.toList());
                  break;
          }
          //Add userList
        List&lt;UserList&gt; userList = new ArrayList&lt;&gt;();
              if(users != null)
                  {
                      users.forEach(userId -&gt;
                      {
                          Optional&lt;Users&gt; user = this.usersRepository.findById(userId);
                            userList.add(new UserList(user.get()));
                      });
              }
          return userList;
      }
  }
  </code></pre>
  <p>As you can see from above I am calling al the data from the user repository and sending it the list</p>
  <p>My customer repository</p>
  <pre><code>public interface ICustomerRepository extends MongoRepository&lt;Customer, String&gt; {
  
  
      Customer findByBusinessInformation_businessName(String businessName);
  
      List&lt;Customer&gt; findByBusinessInformation_partnerAssigned(String partnerAssigned);
  
      @Query(&quot;{ 'LinkedUsers' : ?0 }&quot;)
      Customer findByLinkedUsers(String id);
  
      List&lt;Customer&gt; findAllByLinkedUsersIn(String id);
  }
  </code></pre>
  <p>In the userList I get the error when I add the logic wityh the customerRepository ,without the repository there everything is working(Want to use the repository to get an array of customer and then get the size() of the array and add it to linkedCustomers). Am I missing sommething</p>