Question: How do I avoid passing a service as a parameter in the constructor? If a declare it as an instance, I get a null value. Im using Vaadin14 with Spring Boot and Java v11

```
public interface AccountRoleRepository extends JpaRepository<AccountRole, Long> {
}

@Service
public class AccountRoleRepositoryService {

    @Autowired
    private AccountRoleRepository repository;

    public List<AccountRole> findAll() {
        return repository.findAll();
    }}

@PageTitle("User Access")
@Route(value = "user-access", layout = MainLayout.class)
public class UserAccessView extends Div {

//    @Autowired
//    private AccountRoleRepositoryService accountRoleRepositoryService;  

public UserAccessView(AccountRoleRepositoryService accountRoleRepositoryService) {
    for(AccountRole ar : accountRoleRepositoryService.findAll()){
        System.out.println("role: "+ar.getRole());
    }
}}

```

Answer: 
You should not instantiate @Route classes manually. There's technically nothing preventing you from doing that, but it's almost certainly going to make your code more difficult to understand, and as you have noticed, you can't use Spring dependency injection.
I was able to solve it by implementing a singleton in my service class..

```
@Service
public class AccountRoleRepositoryService {

    private static AccountRoleRepository repository;

    private static AccountRoleRepositoryService INSTANCE;

    private AccountRoleRepositoryService(AccountRoleRepository repository) {
        this.repository = repository;
    }

    public synchronized static AccountRoleRepositoryService getInstance() {
        if(INSTANCE == null) {
            INSTANCE = new AccountRoleRepositoryService(repository);
        }

        return INSTANCE;
    }

    public List<AccountRole> findAll() {
        return repository.findAll();
    }
}

```