lundi 5 février 2018

Should I create a Repository Container to get my repositories in Spring?

@Component
public class RepositoryContainer {
    @Autowired
    public CommentRepository commentRepository;
    @Autowired
    public ItemRepository itemRepository;
    @Autowired
    public UserRepository userRepository;
    @Autowired
    public PostRepository postRepository;
}

In this way, I just need to inject a single god RepositoryContainer and don't need to inject every repository that will pollute my controller.

Aucun commentaire:

Enregistrer un commentaire